Spaces:
Runtime error
Runtime error
tricktreat
commited on
Commit
β’
953b35a
1
Parent(s):
9111154
chitchat
Browse files- awesome_chat.py +14 -5
- config.gradio.yaml +1 -1
- demos/demo_parse_task.json +9 -0
awesome_chat.py
CHANGED
@@ -754,7 +754,7 @@ def run_task(input, command, results, openaikey = None, huggingfacetoken = None)
|
|
754 |
return False
|
755 |
elif task in ["summarization", "translation", "conversational", "text-generation", "text2text-generation"]: # ChatGPT Can do
|
756 |
best_model_id = "ChatGPT"
|
757 |
-
reason = "ChatGPT
|
758 |
choose = {"id": best_model_id, "reason": reason}
|
759 |
messages = [{
|
760 |
"role": "user",
|
@@ -843,10 +843,6 @@ def chat_huggingface(messages, openaikey = None, huggingfacetoken = None, return
|
|
843 |
else:
|
844 |
task_str = task_str.strip()
|
845 |
|
846 |
-
if task_str == "[]": # using LLM response for empty task
|
847 |
-
record_case(success=False, **{"input": input, "task": [], "reason": "task parsing fail: empty", "op": "chitchat"})
|
848 |
-
response = chitchat(messages, openaikey)
|
849 |
-
return response, {}
|
850 |
try:
|
851 |
tasks = json.loads(task_str)
|
852 |
except Exception as e:
|
@@ -854,6 +850,19 @@ def chat_huggingface(messages, openaikey = None, huggingfacetoken = None, return
|
|
854 |
response = chitchat(messages, openaikey)
|
855 |
record_case(success=False, **{"input": input, "task": task_str, "reason": "task parsing fail", "op":"chitchat"})
|
856 |
return response, {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
857 |
|
858 |
|
859 |
tasks = unfold(tasks)
|
|
|
754 |
return False
|
755 |
elif task in ["summarization", "translation", "conversational", "text-generation", "text2text-generation"]: # ChatGPT Can do
|
756 |
best_model_id = "ChatGPT"
|
757 |
+
reason = "ChatGPT performs well on some NLP tasks as well."
|
758 |
choose = {"id": best_model_id, "reason": reason}
|
759 |
messages = [{
|
760 |
"role": "user",
|
|
|
843 |
else:
|
844 |
task_str = task_str.strip()
|
845 |
|
|
|
|
|
|
|
|
|
846 |
try:
|
847 |
tasks = json.loads(task_str)
|
848 |
except Exception as e:
|
|
|
850 |
response = chitchat(messages, openaikey)
|
851 |
record_case(success=False, **{"input": input, "task": task_str, "reason": "task parsing fail", "op":"chitchat"})
|
852 |
return response, {}
|
853 |
+
|
854 |
+
if task_str == "[]": # using LLM response for empty task
|
855 |
+
record_case(success=False, **{"input": input, "task": [], "reason": "task parsing fail: empty", "op": "chitchat"})
|
856 |
+
response = chitchat(messages, openaikey)
|
857 |
+
return response, {}
|
858 |
+
|
859 |
+
if len(tasks)==1 and tasks[0]["task"] in ["summarization", "translation", "conversational", "text-generation", "text2text-generation"]:
|
860 |
+
record_case(success=True, **{"input": input, "task": tasks, "reason": "task parsing fail: empty", "op": "chitchat"})
|
861 |
+
response = chitchat(messages, openaikey)
|
862 |
+
best_model_id = "ChatGPT"
|
863 |
+
reason = "ChatGPT performs well on some NLP tasks as well."
|
864 |
+
choose = {"id": best_model_id, "reason": reason}
|
865 |
+
return response, collect_result(tasks[0], choose, {"response": response})
|
866 |
|
867 |
|
868 |
tasks = unfold(tasks)
|
config.gradio.yaml
CHANGED
@@ -31,4 +31,4 @@ prompt:
|
|
31 |
choose_model: >-
|
32 |
Please choose the most suitable model from {{metas}} for the task {{task}}. The output must be in a strict JSON format: {"id": "id", "reason": "your detail reasons for the choice"}.
|
33 |
response_results: >-
|
34 |
-
Yes. Please first think carefully and directly answer my request based on the inference results. Then please detail your workflow
|
|
|
31 |
choose_model: >-
|
32 |
Please choose the most suitable model from {{metas}} for the task {{task}}. The output must be in a strict JSON format: {"id": "id", "reason": "your detail reasons for the choice"}.
|
33 |
response_results: >-
|
34 |
+
Yes. Please first think carefully and directly answer my request based on the inference results. Some of the inferences may not always turn out to be correct and require you to make careful consideration in making decisions. Then please detail your workflow including the used models and inference results for my request in your friendly tone. Please filter out information that is not relevant to my request. Tell me the complete path or urls of files in inference results. If there is nothing in the results, please tell me you can't make it. }
|
demos/demo_parse_task.json
CHANGED
@@ -52,5 +52,14 @@
|
|
52 |
{
|
53 |
"role": "assistant",
|
54 |
"content": "[{\"task\": \"conversational\", \"id\": 0, \"dep\": [-1], \"args\": {\"text\": \"please show me a joke of cat\" }}, {\"task\": \"text-to-image\", \"id\": 1, \"dep\": [-1], \"args\": {\"text\": \"a photo of cat\" }}]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
]
|
|
|
52 |
{
|
53 |
"role": "assistant",
|
54 |
"content": "[{\"task\": \"conversational\", \"id\": 0, \"dep\": [-1], \"args\": {\"text\": \"please show me a joke of cat\" }}, {\"task\": \"text-to-image\", \"id\": 1, \"dep\": [-1], \"args\": {\"text\": \"a photo of cat\" }}]"
|
55 |
+
},
|
56 |
+
|
57 |
+
{
|
58 |
+
"role": "user",
|
59 |
+
"content": "give me a picture about a cut dog, then describe the image to me and tell a story about it"
|
60 |
+
},
|
61 |
+
{
|
62 |
+
"role": "assistant",
|
63 |
+
"content": "[{\"task\": \"text-to-image\", \"id\": 0, \"dep\": [-1], \"args\": {\"text\": \"a picture of a cut dog\" }}, {\"task\": \"image-to-text\", \"id\": 1, \"dep\": [0], \"args\": {\"image\": \"<GENERATED>-0\" }}, {\"task\": \"text-generation\", \"id\": 2, \"dep\": [1], \"args\": {\"text\": \"<GENERATED>-1\" }}, {\"task\": \"text-to-speech\", \"id\": 3, \"dep\": [2], \"args\": {\"text\": \"<GENERATED>-2\" }}]"
|
64 |
}
|
65 |
]
|