Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,13 +8,23 @@ llm = Llama.from_pretrained(
|
|
| 8 |
)
|
| 9 |
|
| 10 |
basic_prompt = "Below is the context which is your conversation history and the last user question. Write a response according the context and question. ### Context: user: Ответь мне на вопрос о моем здоровье. assistant: Конечно! Какой у Вас вопрос? ### Question: {question} ### Response:"
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
)
|
| 9 |
|
| 10 |
basic_prompt = "Below is the context which is your conversation history and the last user question. Write a response according the context and question. ### Context: user: Ответь мне на вопрос о моем здоровье. assistant: Конечно! Какой у Вас вопрос? ### Question: {question} ### Response:"
|
| 11 |
+
|
| 12 |
+
def generate_response(question):
|
| 13 |
+
model_input = basic_prompt.format(question=input_text)
|
| 14 |
+
if question:
|
| 15 |
+
output = llm(
|
| 16 |
+
model_input, # Prompt
|
| 17 |
+
max_tokens=32, # Generate up to 32 tokens, set to None to generate up to the end of the context window
|
| 18 |
+
stop=["<end_of_turn>"],
|
| 19 |
+
echo=False # Echo the prompt back in the output
|
| 20 |
+
) # Generate a completion, can also call create_completion
|
| 21 |
+
st.write(output["choices"][0]["text"])
|
| 22 |
+
else:
|
| 23 |
+
st.write("Please enter a question to get a response.")
|
| 24 |
+
|
| 25 |
+
# Streamlit text input widget
|
| 26 |
+
input_text = st.text_input('Задайте мне медицинский вопрос...')
|
| 27 |
+
|
| 28 |
+
# Button to trigger response generation
|
| 29 |
+
if st.button('Generate Response'):
|
| 30 |
+
generate_response(input_text)
|