ImPolymath commited on
Commit
ed38779
·
1 Parent(s): ea3503a

update assistant script

Browse files
Files changed (1) hide show
  1. core/demorrha.py +34 -11
core/demorrha.py CHANGED
@@ -124,7 +124,13 @@ class DemorrhaAssistant(object):
124
  )
125
  else:
126
  self.assistant = self.client.beta.assistants.retrieve(assistant_id)
127
-
 
 
 
 
 
 
128
 
129
  def add_file_to_vector_store(self, file_paths):
130
  file_streams = [open(path, "rb") for path in file_paths]
@@ -133,9 +139,29 @@ class DemorrhaAssistant(object):
133
  )
134
  return file_batch
135
 
 
 
 
 
 
 
 
 
 
 
 
136
  def use_assistant(self):
 
137
  # Utiliser l'assistant ici
138
- pass
 
 
 
 
 
 
 
 
139
 
140
  """
141
 
@@ -160,12 +186,9 @@ if __name__ == "__main__":
160
  file_paths = ["style.txt"]
161
  file_batch = demorrha.add_file_to_vector_store(file_paths)
162
  print("Fichier ajouté au vector_store:", file_batch)
163
- """
164
- # Exemple d'utilisation de l'assistant
165
- assistant_id = demorrha.search_assistant("Demorrha")
166
- if assistant_id:
167
- response = demorrha.use_assistant(assistant_id)
168
- print("Réponse de l'assistant:", response)
169
- else:
170
- print("Assistant non trouvé.")
171
- """
 
124
  )
125
  else:
126
  self.assistant = self.client.beta.assistants.retrieve(assistant_id)
127
+ return self
128
+
129
+ def get_assistant(self):
130
+ return self.assistant if not isinstance(self.assistant, None) else None
131
+
132
+ def get_assistant_id(self):
133
+ return self.assistant.id if not isinstance(self.assistant, None) else None
134
 
135
  def add_file_to_vector_store(self, file_paths):
136
  file_streams = [open(path, "rb") for path in file_paths]
 
139
  )
140
  return file_batch
141
 
142
+ def set_payload(self,
143
+ content_message:str,
144
+ operation_prompt: Optional[str] = ""):
145
+ self.payload_content = f'{operation_prompt} :\n"""\n{content_message}\n"""'
146
+ return self
147
+
148
+ def set_system_prompt(self,
149
+ system_prompt: Optional[str] = ""):
150
+ self.system_prompt = system_prompt
151
+ return self
152
+
153
  def use_assistant(self):
154
+ self.set_system_prompt(GlobalSystemPrompts.linguascribe())
155
  # Utiliser l'assistant ici
156
+ run = self.client.beta.threads.create_and_run(
157
+ assistant_id=self.assistant.id,
158
+ thread={
159
+ "messages": [
160
+ {"role": "system", "content": f"{self.system_prompt}"},
161
+ {"role": "user", "content": self.payload_content}
162
+ ]
163
+ }
164
+ )
165
 
166
  """
167
 
 
186
  file_paths = ["style.txt"]
187
  file_batch = demorrha.add_file_to_vector_store(file_paths)
188
  print("Fichier ajouté au vector_store:", file_batch)
189
+
190
+ # Exemple d'utilsation de l'assistant
191
+ demorrha.load_assistant("Demorrha")
192
+ response = demorrha.use_assistant()
193
+ print("Réponse de l'assistant:", response)
194
+