DeL-TaiseiOzaki commited on
Commit
8969ec5
โ€ข
1 Parent(s): fac50d3
Files changed (1) hide show
  1. 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
- if self.current_model == 'claude':
 
 
 
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
- response = self.openai_client.chat.completion.create(
100
- model="gpt-4o",
101
- messages=self._format_messages_for_gpt(),
102
- max_tokens=1024
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)}"