srini047 commited on
Commit
42b59e5
1 Parent(s): 4022498

intial commit

Browse files
Files changed (4) hide show
  1. __pycache__/app.cpython-39.pyc +0 -0
  2. app.py +44 -0
  3. flagged/log.csv +2 -0
  4. requirements.txt +121 -0
__pycache__/app.cpython-39.pyc ADDED
Binary file (1.6 kB). View file
 
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from flask import jsonify, request
3
+ import pandas as pd
4
+ from langchain.utilities import SerpAPIWrapper
5
+ from langchain.agents import Tool
6
+ from langchain.memory import ConversationBufferMemory
7
+ from langchain.llms import Cohere
8
+ from langchain.agents import initialize_agent
9
+ from langchain.agents.agent_types import AgentType
10
+
11
+ COHERE_API_KEY = "CggzsdnWH6QXtnGJvKYe4IRZyGZ8UkTSykpmAigW"
12
+ SERPAPI_API_KEY = "dbc53dd88c7b0957548a81fa162e2d547e03cc19267162a9166e52d4e882f361"
13
+
14
+
15
+ def get_chat_output(prompt: str):
16
+ try:
17
+ search = SerpAPIWrapper(serpapi_api_key=SERPAPI_API_KEY)
18
+ tools = [
19
+ Tool(
20
+ name="Current search",
21
+ func=search.run,
22
+ description="useful for when you need to answer questions about current events or the current state of the world",
23
+ ),
24
+ ]
25
+ memory = ConversationBufferMemory(memory_key="chat_history")
26
+ input = prompt
27
+ llm = Cohere(cohere_api_key=COHERE_API_KEY, model="command-xlarge-nightly")
28
+ agent_chain = initialize_agent(
29
+ tools,
30
+ llm,
31
+ agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,
32
+ verbose=True,
33
+ memory=memory,
34
+ handle_parsing_errors=True,
35
+ )
36
+ response = agent_chain.run(input=input)
37
+ return {"response": response}
38
+
39
+ except:
40
+ return jsonify({"error": "Facing errors, please try again..."})
41
+
42
+
43
+ iface = gr.Interface(fn=get_chat_output, inputs="text", outputs="text")
44
+ iface.launch()
flagged/log.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ prompt,output,flag,username,timestamp
2
+ What are the fashion wear ideas for Women in tech?,,,,2023-08-16 20:38:41.109036
requirements.txt ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ aiohttp==3.8.5
3
+ aiosignal==1.3.1
4
+ altair==5.0.1
5
+ anyio==3.7.1
6
+ appnope==0.1.3
7
+ asttokens==2.2.1
8
+ async-timeout==4.0.2
9
+ attrs==23.1.0
10
+ backcall==0.2.0
11
+ backoff==2.2.1
12
+ blinker==1.6.2
13
+ certifi==2023.7.22
14
+ charset-normalizer==3.2.0
15
+ click==8.1.6
16
+ cohere==4.19.2
17
+ comm==0.1.4
18
+ contourpy==1.1.0
19
+ cycler==0.11.0
20
+ dataclasses-json==0.5.14
21
+ debugpy==1.6.7.post1
22
+ decorator==5.1.1
23
+ exceptiongroup==1.1.3
24
+ executing==1.2.0
25
+ fastapi==0.101.1
26
+ fastavro==1.8.2
27
+ ffmpy==0.3.1
28
+ filelock==3.12.2
29
+ Flask==2.3.2
30
+ Flask-Cors==4.0.0
31
+ fonttools==4.42.0
32
+ frozenlist==1.4.0
33
+ fsspec==2023.6.0
34
+ google-search-results==2.4.2
35
+ gradio==3.40.1
36
+ gradio_client==0.4.0
37
+ h11==0.14.0
38
+ httpcore==0.17.3
39
+ httpx==0.24.1
40
+ huggingface-hub==0.16.4
41
+ idna==3.4
42
+ importlib-metadata==6.8.0
43
+ importlib-resources==6.0.1
44
+ ipykernel==6.25.1
45
+ ipython==8.14.0
46
+ itsdangerous==2.1.2
47
+ jedi==0.19.0
48
+ Jinja2==3.1.2
49
+ joblib==1.3.2
50
+ jsonschema==4.19.0
51
+ jsonschema-specifications==2023.7.1
52
+ jupyter_client==8.3.0
53
+ jupyter_core==5.3.1
54
+ kiwisolver==1.4.4
55
+ langchain==0.0.259
56
+ langsmith==0.0.20
57
+ linkify-it-py==2.0.2
58
+ markdown-it-py==2.2.0
59
+ MarkupSafe==2.1.3
60
+ marshmallow==3.20.1
61
+ matplotlib==3.7.2
62
+ matplotlib-inline==0.1.6
63
+ mdit-py-plugins==0.3.3
64
+ mdurl==0.1.2
65
+ multidict==6.0.4
66
+ mypy-extensions==1.0.0
67
+ nest-asyncio==1.5.7
68
+ numexpr==2.8.5
69
+ numpy==1.22.0
70
+ openai==0.27.8
71
+ openapi-schema-pydantic==1.2.4
72
+ orjson==3.9.4
73
+ packaging==23.1
74
+ pandas==2.0.3
75
+ parso==0.8.3
76
+ pexpect==4.8.0
77
+ pickleshare==0.7.5
78
+ Pillow==10.0.0
79
+ platformdirs==3.10.0
80
+ prompt-toolkit==3.0.39
81
+ psutil==5.9.5
82
+ ptyprocess==0.7.0
83
+ pure-eval==0.2.2
84
+ pydantic==1.10.12
85
+ pydub==0.25.1
86
+ Pygments==2.16.1
87
+ pyparsing==3.0.9
88
+ python-dateutil==2.8.2
89
+ python-multipart==0.0.6
90
+ pytz==2023.3
91
+ PyYAML==6.0.1
92
+ pyzmq==25.1.0
93
+ referencing==0.30.2
94
+ requests==2.31.0
95
+ rpds-py==0.9.2
96
+ scikit-learn==1.3.0
97
+ scipy==1.11.1
98
+ semantic-version==2.10.0
99
+ six==1.16.0
100
+ sniffio==1.3.0
101
+ SQLAlchemy==2.0.19
102
+ stack-data==0.6.2
103
+ starlette==0.27.0
104
+ tabulate==0.9.0
105
+ tenacity==8.2.2
106
+ threadpoolctl==3.2.0
107
+ toolz==0.12.0
108
+ tornado==6.3.2
109
+ tqdm==4.66.0
110
+ traitlets==5.9.0
111
+ typing-inspect==0.9.0
112
+ typing_extensions==4.7.1
113
+ tzdata==2023.3
114
+ uc-micro-py==1.0.2
115
+ urllib3==2.0.4
116
+ uvicorn==0.23.2
117
+ wcwidth==0.2.6
118
+ websockets==11.0.3
119
+ Werkzeug==2.3.6
120
+ yarl==1.9.2
121
+ zipp==3.16.2