Update app.py
Browse files
app.py
CHANGED
@@ -83,7 +83,7 @@ def dspy_generate_agent_prompts(prompt):
|
|
83 |
# Function that accepts a prompt and generates text using the phi2 pipeline
|
84 |
def generate(message, chat_history, max_new_tokens):
|
85 |
|
86 |
-
dspy_generate_agent_prompts(message)
|
87 |
instruction = "You are a helpful organic farming assistant to 'User'. You do not respond as 'User' or pretend to be 'User'. You only respond once as 'Assistant'. You are an agricultural assistant committed to regenerative practices. You are being supplied with a list of tasks which you will need to walk the user through with the compassionate heart of a teacher and using easily understandable language."
|
88 |
final_prompt = f"Instruction: {instruction} {synth_message}\n"
|
89 |
|
@@ -94,6 +94,8 @@ def generate(message, chat_history, max_new_tokens):
|
|
94 |
final_prompt += "User: " + message + "\n"
|
95 |
final_prompt += "Output:"
|
96 |
|
|
|
|
|
97 |
if len(tokenizer.tokenize(final_prompt)) >= tokenizer.model_max_length - max_new_tokens:
|
98 |
final_prompt = "Instruction: Say 'Input exceeded context size, please clear the chat history and retry!' Output:"
|
99 |
|
@@ -119,7 +121,7 @@ def generate(message, chat_history, max_new_tokens):
|
|
119 |
with gr.Blocks() as demo:
|
120 |
gr.Markdown("""
|
121 |
# LEAP Phi-2 Agentic Chatbot Demo
|
122 |
-
This multi-agent chatbot was created for LEAP hackathon, to offer
|
123 |
|
124 |
In order to reduce the response time on this hardware, `max_new_tokens` has been set to `21` in the text generation pipeline. With this default configuration, it takes approximately `60 seconds` for the response to start being generated, and streamed one word at a time. Use the slider below to increase or decrease the length of the generated text.
|
125 |
""")
|
|
|
83 |
# Function that accepts a prompt and generates text using the phi2 pipeline
|
84 |
def generate(message, chat_history, max_new_tokens):
|
85 |
|
86 |
+
synth_message = dspy_generate_agent_prompts(message)
|
87 |
instruction = "You are a helpful organic farming assistant to 'User'. You do not respond as 'User' or pretend to be 'User'. You only respond once as 'Assistant'. You are an agricultural assistant committed to regenerative practices. You are being supplied with a list of tasks which you will need to walk the user through with the compassionate heart of a teacher and using easily understandable language."
|
88 |
final_prompt = f"Instruction: {instruction} {synth_message}\n"
|
89 |
|
|
|
94 |
final_prompt += "User: " + message + "\n"
|
95 |
final_prompt += "Output:"
|
96 |
|
97 |
+
#add the Vectara function for one agent here
|
98 |
+
|
99 |
if len(tokenizer.tokenize(final_prompt)) >= tokenizer.model_max_length - max_new_tokens:
|
100 |
final_prompt = "Instruction: Say 'Input exceeded context size, please clear the chat history and retry!' Output:"
|
101 |
|
|
|
121 |
with gr.Blocks() as demo:
|
122 |
gr.Markdown("""
|
123 |
# LEAP Phi-2 Agentic Chatbot Demo
|
124 |
+
This multi-agent chatbot was created for LEAP hackathon, to offer conversational interface with a team of diverse experts for organic farming advice, using Microsoft's 2.7 billion parameter [phi-2](https://huggingface.co/microsoft/phi-2) Transformer model, Vectara, and DSPy synthetic prompt agentics.
|
125 |
|
126 |
In order to reduce the response time on this hardware, `max_new_tokens` has been set to `21` in the text generation pipeline. With this default configuration, it takes approximately `60 seconds` for the response to start being generated, and streamed one word at a time. Use the slider below to increase or decrease the length of the generated text.
|
127 |
""")
|