Spaces:
Running
Running
DeL-TaiseiOzaki
commited on
Commit
โข
8969ec5
1
Parent(s):
fac50d3
- services/llm_service.py +11 -19
services/llm_service.py
CHANGED
@@ -87,34 +87,26 @@ class LLMService:
|
|
87 |
prompt = self.create_prompt(content, query)
|
88 |
self._add_to_history("user", prompt)
|
89 |
|
90 |
-
|
|
|
|
|
|
|
91 |
response = self.claude_client.messages.create(
|
92 |
model="claude-3-5-sonnet-latest",
|
93 |
-
messages=self._format_messages_for_claude()
|
94 |
-
max_tokens=1024
|
95 |
)
|
96 |
answer = response.content[0].text
|
97 |
|
98 |
else: # gpt
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
)
|
104 |
answer = response.choices[0].message.content
|
105 |
|
106 |
self._add_to_history("assistant", answer)
|
107 |
return answer, None
|
108 |
-
|
109 |
except Exception as e:
|
110 |
-
return None, f"ใจใฉใผใ็บ็ใใพใใ: {str(e)}"
|
111 |
-
|
112 |
-
@staticmethod
|
113 |
-
def format_code_content(files: List[FileInfo]) -> str:
|
114 |
-
"""ใใกใคใซๅ
ๅฎนใใใญใณใใ็จใซใใฉใผใใใ"""
|
115 |
-
formatted_content = []
|
116 |
-
for file_info in files:
|
117 |
-
formatted_content.append(
|
118 |
-
f"#ใใกใคใซใใน\n{file_info.path}\n------------\n{file_info.content}\n"
|
119 |
-
)
|
120 |
-
return "\n".join(formatted_content)
|
|
|
87 |
prompt = self.create_prompt(content, query)
|
88 |
self._add_to_history("user", prompt)
|
89 |
|
90 |
+
print(f"Current model: {self.current_model}") # ใใใใฐ็จๅบๅ
|
91 |
+
|
92 |
+
if self.current_model.lower() == 'claude':
|
93 |
+
print("Using Claude API") # ใใใใฐ็จๅบๅ
|
94 |
response = self.claude_client.messages.create(
|
95 |
model="claude-3-5-sonnet-latest",
|
96 |
+
messages=self._format_messages_for_claude()
|
|
|
97 |
)
|
98 |
answer = response.content[0].text
|
99 |
|
100 |
else: # gpt
|
101 |
+
print("Using GPT API") # ใใใใฐ็จๅบๅ
|
102 |
+
response = openai.chat.completions.create(
|
103 |
+
model="gpt-4",
|
104 |
+
messages=self._format_messages_for_gpt()
|
105 |
)
|
106 |
answer = response.choices[0].message.content
|
107 |
|
108 |
self._add_to_history("assistant", answer)
|
109 |
return answer, None
|
110 |
+
|
111 |
except Exception as e:
|
112 |
+
return None, f"ใจใฉใผใ็บ็ใใพใใ: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|