Spaces:
Sleeping
Sleeping
peterpeter8585
commited on
Commit
•
e807dea
1
Parent(s):
e47f0b6
Update app.py
Browse files
app.py
CHANGED
@@ -97,27 +97,16 @@ def respond(
|
|
97 |
temperature,
|
98 |
top_p,
|
99 |
):
|
100 |
-
messages = [
|
|
|
|
|
|
|
101 |
|
102 |
-
for val in history:
|
103 |
-
if val[0]:
|
104 |
-
messages.append({"role": "user", "content": val[0]})
|
105 |
-
if val[1]:
|
106 |
-
messages.append({"role": "assistant", "content": val[1]})
|
107 |
-
|
108 |
-
messages.append({"role": "user", "content": message})
|
109 |
|
110 |
response = ""
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
max_tokens=max_tokens,
|
115 |
-
stream=True,
|
116 |
-
temperature=temperature,
|
117 |
-
top_p=top_p,
|
118 |
-
):
|
119 |
-
token = message.choices[0].delta.content
|
120 |
-
|
121 |
response += token
|
122 |
yield response
|
123 |
|
|
|
97 |
temperature,
|
98 |
top_p,
|
99 |
):
|
100 |
+
messages = "<s>[SYSTEM] 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. [USER]"+system_message
|
101 |
+
web_results = search(text)
|
102 |
+
web2 = ' '.join([f"Link: {res['link']}\nText: {res['text']}\n\n" for res in web_results])
|
103 |
+
formatted_prompt = system_instructions1 + text + "[WEB]" + str(web2) + "[OpenGPT 4o]"
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
response = ""
|
107 |
|
108 |
+
stream = client.text_generation(formatted_prompt, max_new_tokens=512, stream=True, details=True, return_full_text=False)
|
109 |
+
token="".join([response.token.text for response in stream if response.token.text != "</s>"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
response += token
|
111 |
yield response
|
112 |
|