import os import cohere import gradio as gr import pinecone co = cohere.Client(os.environ.get('COHERE_API', '')) pinecone.init( api_key=os.environ.get('PINECONE_API', ''), environment=os.environ.get('PINECONE_ENV', '') ) def list_me(matches): result = '' for match in matches: result += '
  • ' result += match['metadata']['question'] result += '' if 'body' in match['metadata']: result += '
    ' + match['metadata']['body'] result += '
  • ' return result def query(question): response = co.embed( model='large', texts=[question], ) index = pinecone.Index("gptnyc") closest = index.query( top_k=2, include_metadata=True, vector=response.embeddings[0], ) return '' iface = gr.Interface( fn=query, inputs="text", outputs="html" ) iface.launch()