jozzy commited on
Commit
6c9356d
·
1 Parent(s): 7e54686

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -44,14 +44,15 @@ def init_pinecone(index_name):
44
 
45
 
46
  def process_file(index_name, docs):
47
- init_pinecone(index_name)
48
  embeddings = OpenAIEmbeddings(openai_api_key=os.environ['OPENAI_API_KEY'])
 
49
  #pipeline='zh_core_web_sm'
50
- splter = SpacyTextSplitter(chunk_size=1000,chunk_overlap=200)
51
  split_text = splter.split_documents(docs)
52
 
53
  for document in split_text:
54
- Pinecone.from_documents([document], embeddings, index_name=index_name)
55
 
56
  return list_pinecone(index_name)
57
 
@@ -63,6 +64,8 @@ def list_pinecone(index_name):
63
 
64
 
65
 
 
 
66
  def roleChoice(role):
67
  global messages
68
  messages = [{"role": "system", "content": role}]
@@ -143,7 +146,7 @@ with gr.Blocks() as chatHistory:
143
  role = gr.Interface(fn=roleChoice, inputs="text", outputs="text", description = "Choose your GPT roles, e.g. You are a helpful technology assistant. 你是一位 IT 架构师。 你是一位开发者关系顾问。你是一位机器学习工程师。你是一位高级 C++ 开发人员 ")
144
  text = gr.Interface(fn=textGPT, inputs="text", outputs="text")
145
 
146
- pinecone = gr.Interface(fn=process_file, inputs=["text", "file"], outputs="text")
147
 
148
  #audio = gr.Interface(fn=audioGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
149
  #siri = gr.Interface(fn=siriGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs = "audio")
 
44
 
45
 
46
  def process_file(index_name, docs):
47
+ #init_pinecone(index_name)
48
  embeddings = OpenAIEmbeddings(openai_api_key=os.environ['OPENAI_API_KEY'])
49
+ print(docs)
50
  #pipeline='zh_core_web_sm'
51
+ """splter = SpacyTextSplitter(chunk_size=1000,chunk_overlap=200)
52
  split_text = splter.split_documents(docs)
53
 
54
  for document in split_text:
55
+ Pinecone.from_documents([document], embeddings, index_name=index_name)"""
56
 
57
  return list_pinecone(index_name)
58
 
 
64
 
65
 
66
 
67
+
68
+
69
  def roleChoice(role):
70
  global messages
71
  messages = [{"role": "system", "content": role}]
 
146
  role = gr.Interface(fn=roleChoice, inputs="text", outputs="text", description = "Choose your GPT roles, e.g. You are a helpful technology assistant. 你是一位 IT 架构师。 你是一位开发者关系顾问。你是一位机器学习工程师。你是一位高级 C++ 开发人员 ")
147
  text = gr.Interface(fn=textGPT, inputs="text", outputs="text")
148
 
149
+ pinecone = gr.Interface(fn=process_file, inputs=["text", gradio.inputs.File(file_count="directory")], outputs="text")
150
 
151
  #audio = gr.Interface(fn=audioGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
152
  #siri = gr.Interface(fn=siriGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs = "audio")