Mykes commited on
Commit
f8496a1
1 Parent(s): 3d98c15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
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
- input_text = st.text_input('text')
12
- model_input = basic_prompt.format(question=input_text)
13
- if input_text:
14
- output = llm(
15
- model_input, # Prompt
16
- max_tokens=32, # Generate up to 32 tokens, set to None to generate up to the end of the context window
17
- stop=["<end_of_turn>"],
18
- echo=True # Echo the prompt back in the output
19
- ) # Generate a completion, can also call create_completion
20
- st.write(output["choices"][0]["text"])
 
 
 
 
 
 
 
 
 
 
 
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)