Spaces:
Runtime error
Runtime error
Code refactoring
Browse files
app.py
CHANGED
@@ -6,16 +6,16 @@ import gradio as gr
|
|
6 |
import poe
|
7 |
import os
|
8 |
|
9 |
-
with open(
|
10 |
config = json.load(f)
|
11 |
|
12 |
-
max_questions_count = config[
|
13 |
-
max_tags_count = config[
|
14 |
-
max_attempts = config[
|
15 |
-
wait_time = config[
|
16 |
-
chatgpt_url = config[
|
17 |
-
system_prompt = config[
|
18 |
-
use_sage = config[
|
19 |
sage_token = os.environ['SAGE_TOKEN']
|
20 |
|
21 |
client = poe.Client(sage_token)
|
@@ -23,11 +23,11 @@ client = poe.Client(sage_token)
|
|
23 |
def get_answer(question: str) -> Dict[str, Any]:
|
24 |
|
25 |
if use_sage:
|
26 |
-
for chunk in client.send_message(
|
27 |
pass
|
28 |
return {
|
29 |
'status': True,
|
30 |
-
'content': chunk[
|
31 |
}
|
32 |
|
33 |
headers = {
|
|
|
6 |
import poe
|
7 |
import os
|
8 |
|
9 |
+
with open('config.json', 'r') as f:
|
10 |
config = json.load(f)
|
11 |
|
12 |
+
max_questions_count = config['MAX_QUESTIONS_COUNT']
|
13 |
+
max_tags_count = config['MAX_TAGS_COUNT']
|
14 |
+
max_attempts = config['MAX_ATTEMPS']
|
15 |
+
wait_time = config['WAIT_TIME']
|
16 |
+
chatgpt_url = config['CHATGPT_URL']
|
17 |
+
system_prompt = config['SYSTEM_PROMPT']
|
18 |
+
use_sage = config['USE_SAGE']
|
19 |
sage_token = os.environ['SAGE_TOKEN']
|
20 |
|
21 |
client = poe.Client(sage_token)
|
|
|
23 |
def get_answer(question: str) -> Dict[str, Any]:
|
24 |
|
25 |
if use_sage:
|
26 |
+
for chunk in client.send_message('capybara', question, with_chat_break=True):
|
27 |
pass
|
28 |
return {
|
29 |
'status': True,
|
30 |
+
'content': chunk['text']
|
31 |
}
|
32 |
|
33 |
headers = {
|