forked from adds-rag/TouchlessBrowse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpt_functions.py
118 lines (87 loc) · 3.1 KB
/
gpt_functions.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# This is a file containing all the different functions that ChatGPT will use to run the self instruction code
# These contain just the docstrings and basic idea descriptions. Each function should be its own file to avoid
# overriding each other's work on github pushes.
''' DONE
Function to create a new python file, paste the code that ChatGPT provided and then run it.
Params:
gpt_python_code - a string of the code provided by ChatGPT.
Returns:
Output of the chatGPT code
'''
# def run_gpt_python_code(gpt_python_code):
''' DONE
MAIN FUNCTION
Function to organize and return relevant information from the SERPER API request
Params:
question - a string of the provided question
Returns:
An array containing dictionaries of the relevant information from the Google search in {link, snippet, title} format
'''
# def ask_google_SERP(question): DONE
'''
MAIN FUNCTION
Function to get all text from a website given a URL and return it as a string.
Params:
url - the url of the website to get text from
Returns:
A string of all text from the website
'''
# def get_text_from_website(url): DONE
'''
MAIN FUNCTION
Function to categorize the text from a website into different sections
Params:
raw_text - the raw text from the website, unfiltered
Returns:
A dictionary of all text from the website seperated by categories
'''
# def categorized_gpt_text(raw_text):
# def convert_audio_to_text_WHISPER():
# def convert_user_audio_to_text():
''' DONE
MAIN FUNCTION
Given a dictionary of relevant google search responses, get ChatGPT to provide
a summary of each link
Params:
relevant_search_arr - An array containing dictionaries of the relevant information from the Google search in {link, snippet, title} format
model=4 - use gpt4 or gpt 3.5 model (4 by default)
Returns:
Output from ChatGPT API
'''
# def format_google_results_GPT(relevant_search_dict, model=4):
''' DONE
MAIN FUNCTION
Function to pass text based instructions to GPT.
Params:
instructions - string of instructions to give to ChatGPT
model=4 - use gpt4 or gpt 3.5 model
Returns:
Output from ChatGPT API
'''
# def ask_GPT(instruction, model=4):
'''
MAIN FUNCTION
Given the results provided by ChatGPT of a list of websites to visit, select
the number of the website that the user chose to visit.
Params:
gpt_conversation - the conversation provided by ChatGPT
model - the model to use for ChatGPT (3.5 by default)
Returns:
The number of the website to visit from the list
'''
# def select_website(gpt_conversation, model = 3.5)
'''
MAIN
Function to open a web page in Microsoft Edge
Params:
url - the url of the website to open
'''
# def open_url(url):
'''
MAIN
Function to open a web page from the list of websites provided by ChatGPT
Params:
relevant_search_arr - An array containing dictionaries of the relevant information from the Google search in {link, snippet, title} format
number - the element number of the website to open
'''
# def open_selected(relevant_search_arr, number):