-
Notifications
You must be signed in to change notification settings - Fork 0
/
function-testing.py
38 lines (30 loc) · 963 Bytes
/
function-testing.py
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
37
38
# import openai
# import os
# from dotenv import load_dotenv
# load_dotenv(override=True)
# openapi_key = os.environ['OPENAI_KEY']
# openai.api_key = openapi_key
# #function to generate response using gpt-3
# #takes in users message as input, adds formatting, sends to gpt3 using openai api
# # returns response from gpt3
# def generate_response(message):
# prompt = f"so and so said: {message}"
# response = openai.Completion.create(
# engine="text-davinci-002",
# prompt=prompt,
# max_tokens=50,
# n=1,
# stop=None,
# temperature=0.9,
# )
# print(f"type of response: {type(response)}")
# print(f"value of response: {response}")
# choices = []
# if response.choices is not None:
# for choice in response.choices:
# choices.append(choice)
# if len(choices) > 0:
# return choices[0].text.strip()
# else:
# return "I'm sorry, I don't know how to respond to that."
# generate_response("hello")