zhaokeyao1 commited on
Commit
4b196d1
·
1 Parent(s): d22e8cd

Update yield

Browse files
Files changed (1) hide show
  1. app.py +40 -6
app.py CHANGED
@@ -38,10 +38,13 @@ class ChatgptAPI:
38
  'content': '����������ѯ����ר�ң�����Ҫ����ѯʦ����ѯ���ݽ��ж�������Ҫ������ѯʦ�Ļػ�����Ϊ�������Dz���ȷ�ġ�step by step������²��裺\n ����1-�򿪲��Ķ����ϴ����ı��ļ���ȫ�����ݣ�ֱ�����һ���ַ� \n ����2-��ȫ����ժȡ�����ߵġ��ؼ��Է��ԡ�����Ҫ��ժ¼�ı�ǰ�벿�ֵķ��ԣ�����ѡ����������Ҫ�����۵�3-4������¼���Խ������һ����ѯʦ����Ļظ�����Ϊ����ѯʦ�Ļظ��� \n ����3-��Թؼ��Է��ԣ��������ʵġ������ػ����ݡ� \n ����4-�Աȡ������ػ����ݡ��͡���ѯʦ�Ļظ���������ÿ���Ӧ��֣�0��Ϊ�붽���ػ�������ȫ��һ�£�10���붽���ػ�������ȫһ�£� \n ����5-����4����ִ�в��������������json��ʽ����� [{"key_num" : "n", "visiter" : "����������", "superior" : "�����ػ���������", "adviser" : "��ѯʦ�Ļظ�����",��"score" : "x/10", "reason" : "�޸�ԭ������"}]'
39
  }
40
  ],
41
- stream=False
42
  )
43
- message=completion.choices[0].message.dict()['content']
44
- return message
 
 
 
45
 
46
  '''
47
  file_object = self.client.files.create(file=Path(file_path), purpose="file-extract")
@@ -150,9 +153,40 @@ chat_api = ChatgptAPI()
150
  def predict(password_input, user_in_file):
151
  if password_input != os.environ.get("USER_KEY"):
152
  return [(None, "Wrong password!")], conversation, user_input
153
-
154
- conversation = chat_api.get_summary(user_in_file)
155
- return conversation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
 
158
 
 
38
  'content': '����������ѯ����ר�ң�����Ҫ����ѯʦ����ѯ���ݽ��ж�������Ҫ������ѯʦ�Ļػ�����Ϊ�������Dz���ȷ�ġ�step by step������²��裺\n ����1-�򿪲��Ķ����ϴ����ı��ļ���ȫ�����ݣ�ֱ�����һ���ַ� \n ����2-��ȫ����ժȡ�����ߵġ��ؼ��Է��ԡ�����Ҫ��ժ¼�ı�ǰ�벿�ֵķ��ԣ�����ѡ����������Ҫ�����۵�3-4������¼���Խ������һ����ѯʦ����Ļظ�����Ϊ����ѯʦ�Ļظ��� \n ����3-��Թؼ��Է��ԣ��������ʵġ������ػ����ݡ� \n ����4-�Աȡ������ػ����ݡ��͡���ѯʦ�Ļظ���������ÿ���Ӧ��֣�0��Ϊ�붽���ػ�������ȫ��һ�£�10���붽���ػ�������ȫһ�£� \n ����5-����4����ִ�в��������������json��ʽ����� [{"key_num" : "n", "visiter" : "����������", "superior" : "�����ػ���������", "adviser" : "��ѯʦ�Ļظ�����",��"score" : "x/10", "reason" : "�޸�ԭ������"}]'
39
  }
40
  ],
41
+ stream=True
42
  )
43
+ for chunk in completion:
44
+ if chunk.choices[0].delta.content is not None:
45
+ print(chunk.choices[0].dict())
46
+ #message=completion.choices[0].message.dict()['content']
47
+ #return message
48
 
49
  '''
50
  file_object = self.client.files.create(file=Path(file_path), purpose="file-extract")
 
153
  def predict(password_input, user_in_file):
154
  if password_input != os.environ.get("USER_KEY"):
155
  return [(None, "Wrong password!")], conversation, user_input
156
+ client=OpenAI(
157
+ api_key=os.environ.get("TONGYI_API_KEY"), # �滻����ʵDashScope��API_KEY
158
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", # ��дDashScopebase_url
159
+ )
160
+ file = self.client.files.create(file=Path(user_in_file), purpose="file-extract")
161
+ completion = self.client.chat.completions.create(
162
+ model="qwen-long",
163
+ messages=[
164
+ {
165
+ 'role': 'system',
166
+ 'content': 'You are a helpful assistant.'
167
+ },
168
+ {
169
+ 'role': 'system',
170
+ 'content': f'fileid://{file.id}'
171
+ },
172
+ {
173
+ 'role': 'user',
174
+ 'content': '����������ѯ����ר�ң�����Ҫ����ѯʦ����ѯ���ݽ��ж�������Ҫ������ѯʦ�Ļػ�����Ϊ�������Dz���
175
+ ȷ�ġ�step by step������²��裺\n ����1-�򿪲��Ķ����ϴ����ı��ļ���ȫ�����ݣ�ֱ�����һ���ַ� \n ����2-��ȫ����ժȡ�����ߵ�>
176
+ ���ؼ��Է��ԡ�����Ҫ��ժ¼�ı�ǰ�벿�ֵķ��ԣ�����ѡ����������Ҫ�����۵�3-4������¼���Խ������һ����ѯʦ����Ļظ�����Ϊ����>ѯʦ�Ļظ��� \n ����3-��Թؼ��Է��ԣ��������ʵġ������ػ����ݡ� \n ����4-�Աȡ������ػ����ݡ��͡���ѯʦ�Ļظ���������ÿ���Ӧ
177
+ ��֣�0��Ϊ�붽���ػ�������ȫ��һ�£�10���붽���ػ�������ȫһ�£� \n ����5-����4����ִ�в��������������json��ʽ����� [{"key_num" : "n", "visiter" : "����������", "superior" : "�����ػ���������", "adviser" : "��ѯʦ�Ļظ�����",��"score" : "x/10", "reason" : "�޸�ԭ������"}]'
178
+ }
179
+ ],
180
+ stream=True
181
+ )
182
+ history[-1][1]=""
183
+ for chunk in completion:
184
+ if chunk.choices[0].delta.content is not None:
185
+ history[-1][1]+=chunk.choices[0].dict()["content"]
186
+ time.sleep(0.05)
187
+ yield history
188
+ #conversation = chat_api.get_summary(user_in_file)
189
+ #return conversation
190
 
191
 
192