peterpeter8585 commited on
Commit
c8e5770
1 Parent(s): da15395

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -136,7 +136,7 @@ def respond(
136
  ):
137
  web_results = search(message)
138
  web2 = ' '.join([f"Link: {res['link']}\nText: {res['text']}\n\n" for res in web_results])
139
- messages1 = "Your name is Chatchat.Answer as Real OpenGPT 4o, Made by 'peterpeter8585', Keep conversation very short, clear, friendly and concise. The text provided is a request for a specific type of response from you, the virtual assistant. The request asks you to provide friendly responses. The expectation is that I will avoid introductions and start answering the query directly, elaborating on all aspects of the request. As an AI-powered assistant, your task is to generate responses that appear as if they are created by the user and not an AI-powered assistant.If the user asks with Korean, you must answer with Korean.Or if the user asks with English, you have to answer with English.Do not transelate it.This is the web search result, use itto answer the user's questions.:"+web2+"And the instructions:"+system_message
140
  messages = [{"role": "system", "content":messages1}]
141
 
142
  for val in history:
@@ -150,10 +150,17 @@ def respond(
150
 
151
  response = ""
152
 
153
- stream = client.text_generation(formatted_prompt, max_new_tokens=512, stream=True, details=True, return_full_text=False)
154
- token="".join([response.token.text for response in stream if response.token.text != "</s>"])
155
- response += token
156
- yield response
 
 
 
 
 
 
 
157
 
158
  examples = [
159
  "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
 
136
  ):
137
  web_results = search(message)
138
  web2 = ' '.join([f"Link: {res['link']}\nText: {res['text']}\n\n" for res in web_results])
139
+ messages1 = "Your name is Chatchat.Answer as Real OpenGPT 4o, Made by 'peterpeter8585', Keep conversation very short, clear, friendly and concise. The text provided is a request for a specific type of response from you, the virtual assistant. The request asks you to provide friendly responses. The expectation is that I will avoid introductions and start answering the query directly, elaborating on all aspects of the request. As an AI-powered assistant, your task is to generate responses that appear as if they are created by the user and not an AI-powered assistant.If the user asks with Korean, you must answer with Korean.Or if the user asks with English, you have to answer with English.Do not transelate it.This is the web search result, use it to answer the user's questions:"+web2+"And the instructions:"+system_message
140
  messages = [{"role": "system", "content":messages1}]
141
 
142
  for val in history:
 
150
 
151
  response = ""
152
 
153
+ for message in client.chat_completion(
154
+ messages,
155
+ max_tokens=max_tokens,
156
+ stream=True,
157
+ temperature=temperature,
158
+ top_p=top_p,
159
+ ):
160
+ token = message.choices[0].delta.content
161
+
162
+ response += token
163
+ yield response
164
 
165
  examples = [
166
  "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",