Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import csv
|
|
4 |
import pandas as pd
|
5 |
from analyzer import combine_repo_files_for_llm, analyze_combined_file, parse_llm_json_response
|
6 |
from hf_utils import download_space_repo, search_top_spaces
|
7 |
-
|
8 |
# Import chatbot logic
|
9 |
from analyzer import analyze_code
|
10 |
|
@@ -146,35 +146,8 @@ df_output = gr.Dataframe(headers=["repo id", "strength", "weaknesses", "speciali
|
|
146 |
datatype=["str", "str", "str", "str", "str", "str"]
|
147 |
)
|
148 |
|
149 |
-
|
150 |
-
|
151 |
-
client = OpenAI()
|
152 |
-
messages = [
|
153 |
-
{"role": "system", "content": CHATBOT_SYSTEM_PROMPT}
|
154 |
-
]
|
155 |
-
for msg in history:
|
156 |
-
messages.append({"role": "user", "content": msg[0]})
|
157 |
-
if msg[1]:
|
158 |
-
messages.append({"role": "assistant", "content": msg[1]})
|
159 |
-
messages.append({"role": "user", "content": user_message})
|
160 |
-
response = client.chat.completions.create(
|
161 |
-
model="gpt-4o-mini",
|
162 |
-
messages=messages,
|
163 |
-
max_tokens=256,
|
164 |
-
temperature=0.7
|
165 |
-
)
|
166 |
-
assistant_reply = response.choices[0].message.content
|
167 |
-
return assistant_reply
|
168 |
-
|
169 |
-
def extract_keywords_from_conversation(history):
|
170 |
-
conversation = "\n".join([f"User: {msg[0]}\nAssistant: {msg[1]}" for msg in history if msg[1]])
|
171 |
-
prompt = (
|
172 |
-
"Given the following conversation between a user and an assistant about finding an ideal open-source repo, "
|
173 |
-
"extract about 5 keywords that would be most useful for searching Hugging Face repos to find the most relevant results for the user. "
|
174 |
-
"Return only the keywords as a comma-separated list.\n\nConversation:\n" + conversation
|
175 |
-
)
|
176 |
-
keywords = analyze_code(prompt)
|
177 |
-
return keywords
|
178 |
|
179 |
def use_keywords_to_search_and_update_csv(keywords):
|
180 |
global last_repo_ids, current_repo_idx
|
|
|
4 |
import pandas as pd
|
5 |
from analyzer import combine_repo_files_for_llm, analyze_combined_file, parse_llm_json_response
|
6 |
from hf_utils import download_space_repo, search_top_spaces
|
7 |
+
from chatbot_page import chat_with_user, extract_keywords_from_conversation
|
8 |
# Import chatbot logic
|
9 |
from analyzer import analyze_code
|
10 |
|
|
|
146 |
datatype=["str", "str", "str", "str", "str", "str"]
|
147 |
)
|
148 |
|
149 |
+
|
150 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
def use_keywords_to_search_and_update_csv(keywords):
|
153 |
global last_repo_ids, current_repo_idx
|