Aum-Kansara commited on
Commit
a6a194c
·
1 Parent(s): 92a7811

Delete main.py

Browse files
Files changed (1) hide show
  1. main.py +0 -42
main.py DELETED
@@ -1,42 +0,0 @@
1
- import openai
2
- from dotenv import load_dotenv
3
- import os
4
- from flask import Flask,jsonify,request
5
-
6
- load_dotenv()
7
- openai.api_key=os.getenv("OPENAI_API_KEY")
8
- def sentiment_analysis(transcription):
9
- response = openai.ChatCompletion.create(
10
- model="gpt-3.5-turbo",
11
- temperature=0,
12
- messages=[
13
- {
14
- "role": "system",
15
- "content": "As an AI with expertise in language and emotion analysis, your task is to analyze the sentiment of the following text. Please consider the overall tone of the discussion, the emotion conveyed by the language used, and the context in which words and phrases are used. Indicate whether the sentiment is generally positive, negative, or neutral, and provide brief explanations for your analysis where possible. just say in one word"
16
- },
17
- {
18
- "role": "user",
19
- "content": transcription
20
- }
21
- ]
22
- )
23
- return response['choices'][0]['message']['content']
24
-
25
- app=Flask(__name__)
26
-
27
-
28
- @app.route('/')
29
- def index():
30
- return "Hello World"
31
-
32
- @app.route('/ans')
33
- def sentimentText():
34
- question=request.args.get('que','')
35
- if question.strip()=='':
36
- return "Provide Valid Question"
37
- return jsonify({"question" : question,
38
- "answer" : sentiment_analysis(question)
39
- })
40
-
41
- if __name__=="__main__":
42
- app.run(debug=True)