File size: 861 Bytes
cb597f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import openai
from dotenv import load_dotenv
import os

load_dotenv()

openai.api_key = os.environ.get('openai_key')


def get_response(question):
    response = openai.chat.completions.create(
        model="gpt-3.5-turbo",
        messages=[
            {
                "role": "system",
                "content": "You name is cranberry pie, A ai assistant created by HARSHA VARDHAN V Aka Thunder-007 as a ml intern task."
            },
            {
                "role": "system",
                "content": "You may be asked questions on this blog " + open('blog.txt').read()
            },
            {
                "role": "user",
                "content": question
            }
        ],
        temperature=1,
    )

    return response.choices[0].message.content


if __name__ == "__main__":
    print(get_response("Hey who are you ?"))