Spaces:
Sleeping
Sleeping
pass system prompt to respond func
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
| 7 |
"""
|
| 8 |
# requires space hardware update to use large models (TODO)
|
| 9 |
# client = InferenceClient("mistralai/Mistral-Large-Instruct-2407")
|
| 10 |
-
# Note change in
|
| 11 |
text_generator = pipeline("text-generation", model="EleutherAI/gpt-neo-125M")
|
| 12 |
|
| 13 |
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
@@ -16,7 +16,7 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 16 |
prompt += f"\nUser: {message}\nAssistant:"
|
| 17 |
|
| 18 |
# Generate a response using the model
|
| 19 |
-
response = text_generator(prompt, max_length=max_tokens, temperature=temperature, top_p=top_p, do_sample=True, truncation=
|
| 20 |
|
| 21 |
# Extract the generated text from the response list
|
| 22 |
assistant_response = response[0]['generated_text']
|
|
@@ -27,8 +27,8 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 27 |
"""
|
| 28 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 29 |
"""
|
| 30 |
-
|
| 31 |
-
respond
|
| 32 |
additional_inputs=[
|
| 33 |
gr.Textbox(value=
|
| 34 |
"""
|
|
@@ -59,4 +59,4 @@ demo = gr.ChatInterface(
|
|
| 59 |
)
|
| 60 |
|
| 61 |
if __name__ == "__main__":
|
| 62 |
-
|
|
|
|
| 7 |
"""
|
| 8 |
# requires space hardware update to use large models (TODO)
|
| 9 |
# client = InferenceClient("mistralai/Mistral-Large-Instruct-2407")
|
| 10 |
+
# Note change in instantiation***
|
| 11 |
text_generator = pipeline("text-generation", model="EleutherAI/gpt-neo-125M")
|
| 12 |
|
| 13 |
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
|
|
| 16 |
prompt += f"\nUser: {message}\nAssistant:"
|
| 17 |
|
| 18 |
# Generate a response using the model
|
| 19 |
+
response = text_generator(prompt, max_length=max_tokens, temperature=temperature, top_p=top_p, do_sample=True, truncation=False)
|
| 20 |
|
| 21 |
# Extract the generated text from the response list
|
| 22 |
assistant_response = response[0]['generated_text']
|
|
|
|
| 27 |
"""
|
| 28 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 29 |
"""
|
| 30 |
+
athena = gr.ChatInterface(
|
| 31 |
+
fn=respond
|
| 32 |
additional_inputs=[
|
| 33 |
gr.Textbox(value=
|
| 34 |
"""
|
|
|
|
| 59 |
)
|
| 60 |
|
| 61 |
if __name__ == "__main__":
|
| 62 |
+
athena.launch()
|