Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -82,6 +82,60 @@ cohere_api_key = os.environ['cohere_api']
|
|
82 |
|
83 |
current_dir = os.getcwd()
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
def langchain_document_loader():
|
86 |
"""
|
87 |
Load documents from the temporary directory (TMP_DIR).
|
|
|
82 |
|
83 |
current_dir = os.getcwd()
|
84 |
|
85 |
+
|
86 |
+
|
87 |
+
prompt_templates = {"All Needs Experts": "Respond as if you are combination of all needs assessment experts."}
|
88 |
+
actor_description = {"All Needs Experts": "<div style='float: left;margin: 0px 5px 0px 5px;'><img src='https://na.weshareresearch.com/wp-content/uploads/2023/04/experts2.jpg' alt='needs expert image' style='width:70px;align:top;'></div>A combiation of all needs assessment experts."}
|
89 |
+
|
90 |
+
def get_empty_state():
|
91 |
+
return { "messages": []}
|
92 |
+
|
93 |
+
|
94 |
+
def download_prompt_templates():
|
95 |
+
url = "https://huggingface.co/spaces/ryanrwatkins/needs/raw/main/gurus.txt"
|
96 |
+
try:
|
97 |
+
response = requests.get(url)
|
98 |
+
reader = csv.reader(response.text.splitlines())
|
99 |
+
next(reader) # skip the header row
|
100 |
+
for row in reader:
|
101 |
+
if len(row) >= 2:
|
102 |
+
act = row[0].strip('"')
|
103 |
+
prompt = row[1].strip('"')
|
104 |
+
description = row[2].strip('"')
|
105 |
+
prompt_templates[act] = prompt
|
106 |
+
actor_description[act] = description
|
107 |
+
|
108 |
+
except requests.exceptions.RequestException as e:
|
109 |
+
print(f"An error occurred while downloading prompt templates: {e}")
|
110 |
+
return
|
111 |
+
|
112 |
+
choices = list(prompt_templates.keys())
|
113 |
+
choices = choices[:1] + sorted(choices[1:])
|
114 |
+
return gr.update(value=choices[0], choices=choices)
|
115 |
+
|
116 |
+
def on_prompt_template_change(prompt_template):
|
117 |
+
if not isinstance(prompt_template, str): return
|
118 |
+
return prompt_templates[prompt_template]
|
119 |
+
|
120 |
+
def on_prompt_template_change_description(prompt_template):
|
121 |
+
if not isinstance(prompt_template, str): return
|
122 |
+
return actor_description[prompt_template]
|
123 |
+
|
124 |
+
|
125 |
+
|
126 |
+
|
127 |
+
|
128 |
+
|
129 |
+
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
def langchain_document_loader():
|
140 |
"""
|
141 |
Load documents from the temporary directory (TMP_DIR).
|