jozzy commited on
Commit
99c3774
·
1 Parent(s): 59c047e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -14
app.py CHANGED
@@ -29,14 +29,17 @@ user_db = {os.environ['username1']: os.environ['password1']}
29
  messages = [{"role": "system", "content": 'You are a helpful assistant.'}]
30
 
31
 
 
 
 
 
 
32
 
33
 
34
  def process_file(index_name, dir):
35
-
36
- pinecone.init(
37
- api_key=pinecone_key,
38
- environment=pinecone_environment
39
- )
40
  #using openai embedding hence dim = 1536
41
  pinecone.create_index(index_name, dimension=1536, metric="euclidean")
42
 
@@ -52,17 +55,28 @@ def process_file(index_name, dir):
52
 
53
  #pipeline='zh_core_web_sm'
54
 
55
-
56
-
57
-
58
 
59
- return list_pinecone(index_name)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
 
62
- def list_pinecone(index_name):
63
- index = pinecone.Index(index_name)
64
- stats = index.describe_index_stats()
65
- return stats
66
 
67
 
68
 
@@ -156,7 +170,7 @@ vector_server = gr.Interface(fn=process_file, inputs=["text", gr.inputs.File(fil
156
 
157
  #audio = gr.Interface(fn=audioGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
158
  #siri = gr.Interface(fn=siriGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs = "audio")
159
- file = gr.Interface(fn=fileGPT, inputs=["text", "file"], outputs="text", description = "Enter prompt sentences and your PDF. e.g. lets think step by step, summarize this following text: 或者 让我们一步一步地思考,总结以下的内容:")
160
  demo = gr.TabbedInterface([role, text, file, chatHistory, vector_server], [ "roleChoice", "chatGPT", "fileGPT", "ChatHistory", "VectorServer"])
161
 
162
  if __name__ == "__main__":
 
29
  messages = [{"role": "system", "content": 'You are a helpful assistant.'}]
30
 
31
 
32
+ def init_pinecone():
33
+ pinecone.init(api_key=pinecone_key, environment=pinecone_environment)
34
+ return
35
+
36
+
37
 
38
 
39
  def process_file(index_name, dir):
40
+
41
+ init_pinecone()
42
+
 
 
43
  #using openai embedding hence dim = 1536
44
  pinecone.create_index(index_name, dimension=1536, metric="euclidean")
45
 
 
55
 
56
  #pipeline='zh_core_web_sm'
57
 
 
 
 
58
 
59
+ return
60
+
61
+
62
+ def list_pinecone():
63
+ init_pinecone()
64
+ return pinecone.list_indexes()
65
+
66
+
67
+ def show_pinecone(index_name):
68
+ init_pinecone()
69
+ return pinecone.describe_index(index_name)
70
+
71
+
72
+
73
+ def delete_pinecone(index_name):
74
+ init_pinecone()
75
+ pinecone.delete_index(index_name)
76
+ return
77
+
78
 
79
 
 
 
 
 
80
 
81
 
82
 
 
170
 
171
  #audio = gr.Interface(fn=audioGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
172
  #siri = gr.Interface(fn=siriGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs = "audio")
173
+ file = gr.Interface(fn=fileGPT, inputs=["text", "file"], outputs=None, description = "Enter prompt sentences and your PDF. e.g. lets think step by step, summarize this following text: 或者 让我们一步一步地思考,总结以下的内容:")
174
  demo = gr.TabbedInterface([role, text, file, chatHistory, vector_server], [ "roleChoice", "chatGPT", "fileGPT", "ChatHistory", "VectorServer"])
175
 
176
  if __name__ == "__main__":