tosanoob commited on
Commit
e8b9514
1 Parent(s): 01431a7

Update testing questions

Browse files
arxiv_bot_utils.py ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import chromadb
2
+ from chromadb import Documents, EmbeddingFunction, Embeddings
3
+ from transformers import AutoModel
4
+ import json
5
+ from numpy.linalg import norm
6
+ import sqlite3
7
+ import urllib
8
+
9
+ # this module act as a singleton class
10
+
11
+ class JinaAIEmbeddingFunction(EmbeddingFunction):
12
+ def __init__(self, model):
13
+ super().__init__()
14
+ self.model = model
15
+
16
+ def __call__(self, input: Documents) -> Embeddings:
17
+ embeddings = self.model.encode(input)
18
+ return embeddings.tolist()
19
+
20
+ # instance of embedding_model
21
+ embedding_model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-en',
22
+ trust_remote_code=True,
23
+ cache_dir='models')
24
+
25
+ # instance of JinaAIEmbeddingFunction
26
+ ef = JinaAIEmbeddingFunction(embedding_model)
27
+
28
+ # list of topics
29
+ topic_descriptions = json.load(open("topic_descriptions.txt"))
30
+ topics = list(dict.keys(topic_descriptions))
31
+ embeddings = [embedding_model.encode(topic_descriptions[key]) for key in topic_descriptions]
32
+ cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))
33
+
34
+ def choose_topic(summary):
35
+ embed = embedding_model.encode(summary)
36
+ topic = ""
37
+ max_sim = 0.
38
+ for i,key in enumerate(topics):
39
+ sim = cos_sim(embed,embeddings[i])
40
+ if sim > max_sim:
41
+ topic = key
42
+ max_sim = sim
43
+ return topic
44
+
45
+ def authors_list_to_str(authors):
46
+ """input a list of authors, return a string represent authors"""
47
+ text = ""
48
+ for author in authors:
49
+ text+=author+", "
50
+ return text[:-3]
51
+
52
+ def authors_str_to_list(string):
53
+ """input a string of authors, return a list of authors"""
54
+ authors = []
55
+ list_auth = string.split("and")
56
+ for author in list_auth:
57
+ if author != "et al.":
58
+ authors.append(author.strip())
59
+ return authors
60
+
61
+ def chunk_texts(text, max_char=400):
62
+ """
63
+ Chunk a long text into several chunks, with each chunk about 300-400 characters long,
64
+ but make sure no word is cut in half.
65
+ Args:
66
+ text: The long text to be chunked.
67
+ max_char: The maximum number of characters per chunk (default: 400).
68
+ Returns:
69
+ A list of chunks.
70
+ """
71
+ chunks = []
72
+ current_chunk = ""
73
+ words = text.split()
74
+ for word in words:
75
+ if len(current_chunk) + len(word) + 1 >= max_char:
76
+ chunks.append(current_chunk)
77
+ current_chunk = " "
78
+ else:
79
+ current_chunk += " " + word
80
+ chunks.append(current_chunk.strip())
81
+ return chunks
82
+
83
+ def trimming(txt):
84
+ start = txt.find("{")
85
+ end = txt.rfind("}")
86
+ return txt[start:end+1].replace("\n"," ")
87
+
88
+ # crawl data
89
+
90
+ def extract_tag(txt,tagname):
91
+ return txt[txt.find("<"+tagname+">")+len(tagname)+2:txt.find("</"+tagname+">")]
92
+
93
+ def get_record(extract):
94
+ id = extract_tag(extract,"id")
95
+ updated = extract_tag(extract,"updated")
96
+ published = extract_tag(extract,"published")
97
+ title = extract_tag(extract,"title").replace("\n ","").strip()
98
+ summary = extract_tag(extract,"summary").replace("\n","").strip()
99
+ authors = []
100
+ while extract.find("<author>")!=-1:
101
+ # author = extract[extract.find("<name>")+6:extract.find("</name>")]
102
+ author = extract_tag(extract,"name")
103
+ extract = extract[extract.find("</author>")+9:]
104
+ authors.append(author)
105
+ pattern = '<link title="pdf" href="'
106
+ link_start = extract.find('<link title="pdf" href="')
107
+ link = extract[link_start+len(pattern):extract.find("rel=",link_start)-2]
108
+ return [id, updated, published, title, authors, link, summary]
109
+
110
+ def crawl_exact_paper(title,author,max_results=3):
111
+ authors = authors_list_to_str(author)
112
+ records = []
113
+ url = 'http://export.arxiv.org/api/query?search_query=ti:{title}+AND+au:{author}&max_results={max_results}'.format(title=title,author=authors,max_results=max_results)
114
+ url = url.replace(" ","%20")
115
+ try:
116
+ arxiv_page = urllib.request.urlopen(url,timeout=100).read()
117
+ xml = str(arxiv_page,encoding="utf-8")
118
+ while xml.find("<entry>") != -1:
119
+ extract = xml[xml.find("<entry>")+7:xml.find("</entry>")]
120
+ xml = xml[xml.find("</entry>")+8:]
121
+ extract = get_record(extract)
122
+ topic = choose_topic(extract[6])
123
+ records.append([topic,*extract])
124
+ return records
125
+ except Exception as e:
126
+ return "Error: "+str(e)
127
+
128
+ def crawl_arxiv(keyword_list, max_results=100):
129
+ baseurl = 'http://export.arxiv.org/api/query?search_query='
130
+ records = []
131
+ for i,keyword in enumerate(keyword_list):
132
+ if i ==0:
133
+ url = baseurl + 'all:' + keyword
134
+ else:
135
+ url = url + '+OR+' + 'all:' + keyword
136
+ url = url+ '&max_results=' + str(max_results)
137
+ url = url.replace(' ', '%20')
138
+ try:
139
+ arxiv_page = urllib.request.urlopen(url,timeout=100).read()
140
+ xml = str(arxiv_page,encoding="utf-8")
141
+ while xml.find("<entry>") != -1:
142
+ extract = xml[xml.find("<entry>")+7:xml.find("</entry>")]
143
+ xml = xml[xml.find("</entry>")+8:]
144
+ extract = get_record(extract)
145
+ topic = choose_topic(extract[6])
146
+ records.append([topic,*extract])
147
+ return records
148
+ except Exception as e:
149
+ return "Error: "+str(e)
150
+
151
+ class ArxivSQL:
152
+ def __init__(self, table="arxivsql", name="arxiv_records_sql"):
153
+ self.con = sqlite3.connect(name)
154
+ self.cur = self.con.cursor()
155
+ self.table = table
156
+
157
+ def query(self, title="", author=[]):
158
+ if len(title)>0:
159
+ query_title = 'title like "%{}%"'.format(title)
160
+ else:
161
+ query_title = "True"
162
+ if len(author)>0:
163
+ query_author = 'authors like '
164
+ for auth in author:
165
+ query_author += "'%{}%' or ".format(auth)
166
+ query_author = query_author[:-4]
167
+ else:
168
+ query_author = "True"
169
+ query = "select * from {} where {} and {}".format(self.table,query_title,query_author)
170
+ result = self.cur.execute(query)
171
+ return result.fetchall()
172
+
173
+ def query_id(self, ids=[]):
174
+ try:
175
+ if len(ids) == 0:
176
+ return None
177
+ query = "select * from {} where id in (".format(self.table)
178
+ for id in ids:
179
+ query+="'"+id+"',"
180
+ query = query[:-1] + ")"
181
+ result = self.cur.execute(query)
182
+ return result.fetchall()
183
+ except Exception as e:
184
+ print(e)
185
+ print("Error query: ",query)
186
+
187
+ def add(self, crawl_records):
188
+ """
189
+ Add crawl_records (list) obtained from arxiv_crawlers
190
+ A record is a list of 8 columns:
191
+ [topic, id, updated, published, title, author, link, summary]
192
+ Return the final length of the database table
193
+ """
194
+ results = ""
195
+ for record in crawl_records:
196
+ try:
197
+ query = """insert into arxivsql values("{}","{}","{}","{}","{}","{}","{}")""".format(
198
+ record[1][21:],
199
+ record[0],
200
+ record[4].replace('"',"'"),
201
+ authors_list_to_str(record[5]),
202
+ record[2][:10],
203
+ record[3][:10],
204
+ record[6]
205
+ )
206
+ self.cur.execute(query)
207
+ self.con.commit()
208
+ except Exception as e:
209
+ result+=str(e)
210
+ result+="\n" + query + "\n"
211
+ finally:
212
+ return results
213
+
214
+ # instance of ArxivSQL
215
+ sqldb = ArxivSQL()
216
+
217
+ class ArxivChroma:
218
+ """
219
+ Create an interface to arxivdb, which only support query and addition.
220
+ This interface do not support edition and deletion procedures.
221
+ """
222
+ def __init__(self, table="arxiv_records", name="arxivdb/"):
223
+ self.client = chromadb.PersistentClient(name)
224
+ self.model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-en',
225
+ trust_remote_code=True,
226
+ cache_dir='models')
227
+ self.collection = self.client.get_or_create_collection(table,
228
+ embedding_function=JinaAIEmbeddingFunction(
229
+ model = self.model
230
+ ))
231
+
232
+ def query_relevant(self, keywords, query_texts, n_results=3):
233
+ """
234
+ Perform a query using a list of keywords (str),
235
+ or using a relavant string
236
+ """
237
+ contains = []
238
+ for keyword in keywords:
239
+ contains.append({"$contains":keyword.lower()})
240
+ return self.collection.query(
241
+ query_texts=query_texts,
242
+ where_document={
243
+ "$or":contains
244
+ },
245
+ n_results=n_results,
246
+ )
247
+
248
+ def query_exact(self, id):
249
+ ids = ["{}_{}".format(id,j) for j in range(0,10)]
250
+ return self.collection.get(ids=ids)
251
+
252
+ def add(self, crawl_records):
253
+ """
254
+ Add crawl_records (list) obtained from arxiv_crawlers
255
+ A record is a list of 8 columns:
256
+ [topic, id, updated, published, title, author, link, summary]
257
+ Return the final length of the database table
258
+ """
259
+ for record in crawl_records:
260
+ embed_text = """
261
+ Topic: {},
262
+ Title: {},
263
+ Summary: {}
264
+ """.format(record[0],record[4],record[7])
265
+ chunks = chunk_texts(embed_text)
266
+ ids = [record[1][21:]+"_"+str(j) for j in range(len(chunks))]
267
+ paper_ids = [{"paper_id":record[1][21:]} for _ in range(len(chunks))]
268
+ self.collection.add(
269
+ documents = chunks,
270
+ metadatas=paper_ids,
271
+ ids = ids
272
+ )
273
+ return self.collection.count()
274
+
275
+ # instance of ArxivChroma
276
+ db = ArxivChroma()
277
+
prebuild.ipynb ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 3,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stderr",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "C:\\Users\\Admin\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
13
+ " from .autonotebook import tqdm as notebook_tqdm\n"
14
+ ]
15
+ }
16
+ ],
17
+ "source": [
18
+ "import google.generativeai as genai\n",
19
+ "import arxiv_bot_utils as utils\n",
20
+ "import os\n",
21
+ "from getpass import getpass\n",
22
+ "import json"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": 4,
28
+ "metadata": {},
29
+ "outputs": [
30
+ {
31
+ "name": "stdout",
32
+ "output_type": "stream",
33
+ "text": [
34
+ "models/gemini-1.0-pro\n",
35
+ "models/gemini-1.0-pro-001\n",
36
+ "models/gemini-1.0-pro-latest\n",
37
+ "models/gemini-1.0-pro-vision-latest\n",
38
+ "models/gemini-1.5-pro-latest\n",
39
+ "models/gemini-pro\n",
40
+ "models/gemini-pro-vision\n"
41
+ ]
42
+ }
43
+ ],
44
+ "source": [
45
+ "os.environ['GEMINI_API_KEY'] = getpass(\"Input your API key: \")\n",
46
+ "\n",
47
+ "gemini_api_key = os.getenv(\"GEMINI_API_KEY\")\n",
48
+ "if not gemini_api_key:\n",
49
+ " raise ValueError(\n",
50
+ " \"Gemini API Key not provided. Please provide GEMINI_API_KEY as an environment variable\"\n",
51
+ " )\n",
52
+ "genai.configure(api_key=gemini_api_key)\n",
53
+ "for m in genai.list_models():\n",
54
+ " if 'generateContent' in m.supported_generation_methods:\n",
55
+ " print(m.name)\n"
56
+ ]
57
+ },
58
+ {
59
+ "cell_type": "code",
60
+ "execution_count": 6,
61
+ "metadata": {},
62
+ "outputs": [],
63
+ "source": [
64
+ "config = genai.GenerationConfig(max_output_tokens=2048,\n",
65
+ " temperature=0.7)\n",
66
+ "safety_settings = [\n",
67
+ " {\n",
68
+ " \"category\": \"HARM_CATEGORY_DANGEROUS\",\n",
69
+ " \"threshold\": \"BLOCK_NONE\",\n",
70
+ " },\n",
71
+ " {\n",
72
+ " \"category\": \"HARM_CATEGORY_HARASSMENT\",\n",
73
+ " \"threshold\": \"BLOCK_NONE\",\n",
74
+ " },\n",
75
+ " {\n",
76
+ " \"category\": \"HARM_CATEGORY_HATE_SPEECH\",\n",
77
+ " \"threshold\": \"BLOCK_NONE\",\n",
78
+ " },\n",
79
+ " {\n",
80
+ " \"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n",
81
+ " \"threshold\": \"BLOCK_NONE\",\n",
82
+ " },\n",
83
+ " {\n",
84
+ " \"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\",\n",
85
+ " \"threshold\": \"BLOCK_NONE\",\n",
86
+ " },\n",
87
+ "]\n",
88
+ "model = genai.GenerativeModel(\"gemini-pro\",\n",
89
+ " generation_config=config,\n",
90
+ " safety_settings=safety_settings)"
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "code",
95
+ "execution_count": 7,
96
+ "metadata": {},
97
+ "outputs": [],
98
+ "source": [
99
+ "def extract_keyword_prompt(query):\n",
100
+ " \"\"\"A prompt that return a JSON block as arguments for querying database\"\"\"\n",
101
+ "\n",
102
+ " prompt = (\n",
103
+ " \"\"\"[INST] SYSTEM: You are an assistant that choose only one action below based on guest question.\n",
104
+ " 1. If the guest question is asking for a single specific document or article with explicit title, you need to respond the information in JSON format with 2 keys \"title\", \"author\" if found any above. The authors are separated with the word 'and'. \n",
105
+ " 2. If the guest question is asking for relevant informations about a topic, you need to respond the information in JSON format with 2 keys \"keywords\", \"description\", include a list of keywords represent the main academic topic, \\\n",
106
+ " and a description about the main topic. You may paraphrase the keywords to add more. \\\n",
107
+ " 3. If the guest is not asking for any informations or documents, you need to respond with a polite answer in JSON format with 1 key \"answer\".\n",
108
+ " QUESTION: '{query}'\n",
109
+ " [/INST]\n",
110
+ " ANSWER: \n",
111
+ " \"\"\"\n",
112
+ " ).format(query=query)\n",
113
+ "\n",
114
+ " return prompt\n",
115
+ "\n",
116
+ "def make_answer_prompt(input, contexts):\n",
117
+ " \"\"\"A prompt that return the final answer, based on the queried context\"\"\"\n",
118
+ "\n",
119
+ " prompt = (\n",
120
+ " \"\"\"[INST] You are a library assistant that help to search articles and documents based on user's question.\n",
121
+ " From guest's question, you have found some records and documents that may help. Now you need to answer the guest with the information found.\n",
122
+ " If no information found in the database, you may generate some other recommendation related to user's question using your own knowledge. Each article or paper must have a link to the pdf download page.\n",
123
+ " You should answer in a conversational form politely.\n",
124
+ " QUESTION: '{input}'\n",
125
+ " INFORMATION: '{contexts}'\n",
126
+ " [/INST]\n",
127
+ " ANSWER:\n",
128
+ " \"\"\"\n",
129
+ " ).format(input=input, contexts=contexts)\n",
130
+ "\n",
131
+ " return prompt"
132
+ ]
133
+ },
134
+ {
135
+ "cell_type": "code",
136
+ "execution_count": 12,
137
+ "metadata": {},
138
+ "outputs": [],
139
+ "source": [
140
+ "def response(args):\n",
141
+ " \"\"\"Create response context, based on input arguments\"\"\"\n",
142
+ " keys = list(dict.keys(args))\n",
143
+ " if \"answer\" in keys:\n",
144
+ " return args['answer'], None # trả lời trực tiếp\n",
145
+ " \n",
146
+ " if \"keywords\" in keys:\n",
147
+ " # perform query\n",
148
+ " query_texts = args[\"description\"]\n",
149
+ " keywords = args[\"keywords\"]\n",
150
+ " results = utils.db.query_relevant(keywords=keywords, query_texts=query_texts)\n",
151
+ " # print(results)\n",
152
+ " ids = results['metadatas'][0]\n",
153
+ " if len(ids) == 0:\n",
154
+ " # go crawl some\n",
155
+ " new_records = utils.crawl_arxiv(keyword_list=keywords, max_results=10)\n",
156
+ " print(\"Got new records: \",len(new_records))\n",
157
+ " if type(new_records) == str:\n",
158
+ " return \"Error occured, information not found\", new_records\n",
159
+ " utils.db.add(new_records)\n",
160
+ " utils.sqldb.add(new_records)\n",
161
+ " results = utils.db.query_relevant(keywords=keywords, query_texts=query_texts)\n",
162
+ " ids = results['metadatas'][0]\n",
163
+ " print(\"Re-queried on chromadb, results: \",ids)\n",
164
+ " paper_id = [id['paper_id'] for id in ids]\n",
165
+ " paper_info = utils.sqldb.query_id(paper_id)\n",
166
+ " print(paper_info)\n",
167
+ " records = [] # get title (2), author (3), link (6)\n",
168
+ " result_string = \"\"\n",
169
+ " if paper_info:\n",
170
+ " for i in range(len(paper_info)):\n",
171
+ " result_string += \"Title: {}, Author: {}, Link: {}\".format(paper_info[i][2],paper_info[i][3],paper_info[i][6])\n",
172
+ " records.append([paper_info[i][2],paper_info[i][3],paper_info[i][6]])\n",
173
+ " return result_string, records\n",
174
+ " else:\n",
175
+ " return \"Information not found\", \"Information not found\"\n",
176
+ " # invoke llm and return result\n",
177
+ "\n",
178
+ " if \"title\" in keys:\n",
179
+ " title = args['title']\n",
180
+ " authors = utils.authors_str_to_list(args['author'])\n",
181
+ " paper_info = utils.sqldb.query(title = title,author = authors)\n",
182
+ " # if query not found then go crawl brh\n",
183
+ " # print(paper_info)\n",
184
+ "\n",
185
+ " if len(paper_info) == 0:\n",
186
+ " new_records = utils.crawl_exact_paper(title=title,author=authors)\n",
187
+ " print(\"Got new records: \",len(new_records))\n",
188
+ " if type(new_records) == str:\n",
189
+ " # print(new_records)\n",
190
+ " return \"Error occured, information not found\", \"Information not found\"\n",
191
+ " utils.db.add(new_records)\n",
192
+ " utils.sqldb.add(new_records)\n",
193
+ " paper_info = utils.sqldb.query(title = title,author = authors)\n",
194
+ " print(\"Re-queried on chromadb, results: \",paper_info)\n",
195
+ " # -------------------------------------\n",
196
+ " records = [] # get title (2), author (3), link (6)\n",
197
+ " result_string = \"\"\n",
198
+ " for i in range(len(paper_info)):\n",
199
+ " result_string += \"Title: {}, Author: {}, Link: {}\".format(paper_info[i][2],paper_info[i][3],paper_info[i][6])\n",
200
+ " records.append([paper_info[i][2],paper_info[i][3],paper_info[i][6]])\n",
201
+ " # process results:\n",
202
+ " if len(result_string) == 0:\n",
203
+ " return \"Information not found\", \"Information not found\"\n",
204
+ " return result_string, records\n",
205
+ " # invoke llm and return result"
206
+ ]
207
+ },
208
+ {
209
+ "cell_type": "code",
210
+ "execution_count": 9,
211
+ "metadata": {},
212
+ "outputs": [],
213
+ "source": [
214
+ "def full_chain_single_question(input_prompt):\n",
215
+ " try:\n",
216
+ " first_prompt = extract_keyword_prompt(input_prompt)\n",
217
+ " temp_answer = model.generate_content(first_prompt).text\n",
218
+ "\n",
219
+ " args = json.loads(utils.trimming(temp_answer))\n",
220
+ " contexts, results = response(args)\n",
221
+ " if not results:\n",
222
+ " print(contexts)\n",
223
+ " else:\n",
224
+ " output_prompt = make_answer_prompt(input_prompt,contexts)\n",
225
+ " answer = model.generate_content(output_prompt).text\n",
226
+ " return temp_answer, answer\n",
227
+ " except Exception as e:\n",
228
+ " print(e)\n",
229
+ " return temp_answer, \"Error occured: \" + str(e)"
230
+ ]
231
+ },
232
+ {
233
+ "cell_type": "code",
234
+ "execution_count": 27,
235
+ "metadata": {},
236
+ "outputs": [
237
+ {
238
+ "name": "stdout",
239
+ "output_type": "stream",
240
+ "text": [
241
+ "[('1903.04824v1', 'computer science', 'Proceedings of the Fifth International Conference on Cloud and Robotics (ICCR2018)', ' Huaxi, Zhang, Jacques Malenfan', '2019-03-12', '2019-03-12', 'http://arxiv.org/pdf/1903.04824v1'), ('1709.07597v1', 'economics', 'Inverse Reinforcement Learning with Conditional Choice Probabilities', 'Mohit Sharma, Kris M. Kitani, Joachim Groege', '2017-09-22', '2017-09-22', 'http://arxiv.org/pdf/1709.07597v1')]\n",
242
+ "Sure, here are some key papers on model predictive control for nonlinear systems:\n",
243
+ "\n",
244
+ "* **Nonlinear Model Predictive Control: A Survey** by Garcia, P.D., Prett, D.M., and Morari, M. (1989)\n",
245
+ "* **Model Predictive Control for Nonlinear Systems** by Camacho, E.F. and Bordons, C. (1999)\n",
246
+ "* **Nonlinear Model Predictive Control** by Rawlings, J.B. and Mayne, D.Q. (2009)\n",
247
+ "\n",
248
+ "As for recent reviews on the application of control theory to robotics, here are a few:\n",
249
+ "\n",
250
+ "* **Control of Robot Manipulators** by Spong, M.W., Hutchinson, S., and Vidyasagar, M. (2006)\n",
251
+ "* **Robotics: Modelling, Planning and Control** by Siciliano, B., Sciavicco, L., Villani, L., and Oriolo, G. (2010)\n",
252
+ "* **Control of Robot Arms** by Featherstone, R. (2014)\n",
253
+ "\n",
254
+ "I hope this information is helpful. Please let me know if you have any other questions.\n"
255
+ ]
256
+ }
257
+ ],
258
+ "source": [
259
+ "# test response, second step\n",
260
+ "input_prompt = \"Can you suggest some key papers on model predictive control for nonlinear systems, and are there any recent reviews on the application of control theory to robotics?\"\n",
261
+ "args = \"{\\n \\\"keywords\\\": [\\\"Model predictive control\\\", \\\"Nonlinear systems\\\", \\\"Robotics\\\", \\\"Control theory\\\"],\\n \\\"description\\\": \\\"Model predictive control (MPC) is a control algorithm that uses a model of the system to predict future behavior and optimize the control inputs. MPC is particularly well-suited for nonlinear systems, as it can handle the complex dynamics of these systems. In recent years, MPC has been increasingly applied to robotics, as it can improve the performance and safety of robotic systems. Control theory is a branch of mathematics that deals with the analysis and design of control systems. Control theory has been applied to a wide range of problems in robotics, including motion planning, trajectory tracking, and force control.\\\"\\n}\"\n",
262
+ "args = json.loads(args)\n",
263
+ "contexts, results = response(args)\n",
264
+ "if not results:\n",
265
+ " # direct answer\n",
266
+ " print(contexts)\n",
267
+ "else:\n",
268
+ " output_prompt = make_answer_prompt(input_prompt,contexts)\n",
269
+ " answer = model.generate_content(output_prompt).text\n",
270
+ " print(answer)"
271
+ ]
272
+ },
273
+ {
274
+ "cell_type": "code",
275
+ "execution_count": 13,
276
+ "metadata": {},
277
+ "outputs": [
278
+ {
279
+ "name": "stdout",
280
+ "output_type": "stream",
281
+ "text": [
282
+ "{'desired': 'Natural Language Processing (Computer Science)', 'question': 'What are some recent papers on deep learning architectures for text classification, and can you recommend any surveys or reviews on the topic?'}\n",
283
+ "0\n",
284
+ "[('1904.08067v5', 'computer science', 'Text Classification Algorithms: A Survey', 'Kamran Kowsari, Kiana Jafari Meimandi, Mojtaba Heidarysafa, Sanjana Mendu, Laura E. Barnes, Donald E. Brow', '2020-05-20', '2019-04-17', 'http://arxiv.org/pdf/1904.08067v5'), ('1910.11470v1', 'computer science', 'A Survey on Recent Advances in Named Entity Recognition from Deep Learning models', 'Vikas Yadav, Steven Bethar', '2019-10-25', '2019-10-25', 'http://arxiv.org/pdf/1910.11470v1'), ('1710.04288v1', 'electrical engineering and system science', 'Audio Concept Classification with Hierarchical Deep Neural Networks', 'Mirco Ravanelli, Benjamin Elizalde, Karl Ni, Gerald Friedlan', '2017-10-11', '2017-10-11', 'http://arxiv.org/pdf/1710.04288v1')]\n",
285
+ "1\n",
286
+ "[('1601.04187v1', 'computer science', 'Conversion of Artificial Recurrent Neural Networks to Spiking Neural Networks for Low-power Neuromorphic Hardware', 'Peter U. Diehl, Guido Zarrella, Andrew Cassidy, Bruno U. Pedroni, Emre Neftc', '2016-01-16', '2016-01-16', 'http://arxiv.org/pdf/1601.04187v1'), ('1801.01093v3', 'economics', 'Comparing the Forecasting Performances of Linear Models for Electricity Prices with High RES Penetration', 'Angelica Gianfreda, Francesco Ravazzolo, Luca Rossin', '2019-11-12', '2018-01-03', 'http://arxiv.org/pdf/1801.01093v3'), ('2302.11093v1', 'electrical engineering and system science', 'Use Cases for Time-Frequency Image Representations and Deep Learning Techniques for Improved Signal Classification', 'Mehmet Parla', '2023-02-22', '2023-02-22', 'http://arxiv.org/pdf/2302.11093v1')]\n",
287
+ "2\n",
288
+ "[('1505.07907v4', 'economics', 'Linking Economic Complexity, Institutions and Income Inequality', 'D. Hartmann, M. R. Guevara, C. Jara-Figueroa, M. Aristaran, C. A. Hidalg', '2017-01-04', '2015-05-29', 'http://arxiv.org/pdf/1505.07907v4'), ('2201.09806v1', 'economics', 'Infinite Growth: A Curse or a Blessing?', 'Gennady Shkliarevsk', '2022-01-24', '2022-01-24', 'http://arxiv.org/pdf/2201.09806v1'), ('1910.11780v1', 'economics', 'Inequality in Turkey: Looking Beyond Growth', 'Bayram Cakir, Ipek Ergu', '2019-10-25', '2019-10-25', 'http://arxiv.org/pdf/1910.11780v1')]\n",
289
+ "3\n",
290
+ "[('1607.06583v2', 'computer science', \"Classification of Alzheimer's Disease Structural MRI Data by Deep Learning Convolutional Neural Networks\", 'Saman Sarraf, Ghassem Tofigh', '2017-05-19', '2016-07-22', 'http://arxiv.org/pdf/1607.06583v2'), ('1804.02527v1', 'computer science', 'Visual Analytics for Explainable Deep Learning', 'Jaegul Choo, Shixia Li', '2018-04-07', '2018-04-07', 'http://arxiv.org/pdf/1804.02527v1'), ('2208.03143v1', 'computer science', 'Deep Learning and Health Informatics for Smart Monitoring and Diagnosis', 'Amin Gasm', '2022-08-05', '2022-08-05', 'http://arxiv.org/pdf/2208.03143v1')]\n",
291
+ "4\n",
292
+ "Got new records: 10\n",
293
+ "Re-queried on chromadb, results: []\n",
294
+ "None\n",
295
+ "5\n",
296
+ "[('2308.16539v2', 'computer science', 'On a Connection between Differential Games, Optimal Control, and Energy-based Models for Multi-Agent Interactions', 'Christopher Diehl, Tobias Klosek, Martin Krüger, Nils Murzyn, Torsten Bertra', '2023-10-16', '2023-08-31', 'http://arxiv.org/pdf/2308.16539v2'), ('2008.13221v1', 'computer science', 'Human-in-the-Loop Methods for Data-Driven and Reinforcement Learning Systems', 'Vinicius G. Goeck', '2020-08-30', '2020-08-30', 'http://arxiv.org/pdf/2008.13221v1')]\n",
297
+ "6\n",
298
+ "Expecting ',' delimiter: line 1 column 498 (char 497)\n",
299
+ "7\n",
300
+ "[('2101.00793v2', 'computer science', 'A Framework for Fast Scalable BNN Inference using Googlenet and Transfer Learning', 'Karthik ', '2021-01-05', '2021-01-04', 'http://arxiv.org/pdf/2101.00793v2')]\n",
301
+ "8\n",
302
+ "[('1803.04840v1', 'electrical engineering and system science', 'Resource aware design of a deep convolutional-recurrent neural network for speech recognition through audio-visual sensor fusion', 'Matthijs Van keirsbilck, Bert Moons, Marian Verhels', '2018-03-13', '2018-03-13', 'http://arxiv.org/pdf/1803.04840v1'), ('1004.3275v1', 'electrical engineering and system science', 'C Implementation &amp; comparison of companding &amp; silence audio compression techniques', 'Kruti Dangarwala, Jigar Sha', '2010-04-19', '2010-04-19', 'http://arxiv.org/pdf/1004.3275v1'), ('2108.05684v2', 'electrical engineering and system science', 'RW-Resnet: A Novel Speech Anti-Spoofing Model Using Raw Waveform', 'Youxuan Ma, Zongze Ren, Shugong X', '2021-08-13', '2021-08-12', 'http://arxiv.org/pdf/2108.05684v2')]\n",
303
+ "500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting\n",
304
+ "9\n",
305
+ "500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting\n"
306
+ ]
307
+ },
308
+ {
309
+ "ename": "UnboundLocalError",
310
+ "evalue": "local variable 'temp_answer' referenced before assignment",
311
+ "output_type": "error",
312
+ "traceback": [
313
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
314
+ "\u001b[1;31mInternalServerError\u001b[0m Traceback (most recent call last)",
315
+ "Cell \u001b[1;32mIn[9], line 4\u001b[0m, in \u001b[0;36mfull_chain_single_question\u001b[1;34m(input_prompt)\u001b[0m\n\u001b[0;32m 3\u001b[0m first_prompt \u001b[38;5;241m=\u001b[39m extract_keyword_prompt(input_prompt)\n\u001b[1;32m----> 4\u001b[0m temp_answer \u001b[38;5;241m=\u001b[39m \u001b[43mmodel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgenerate_content\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfirst_prompt\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mtext\n\u001b[0;32m 6\u001b[0m args \u001b[38;5;241m=\u001b[39m json\u001b[38;5;241m.\u001b[39mloads(utils\u001b[38;5;241m.\u001b[39mtrimming(temp_answer))\n",
316
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\generativeai\\generative_models.py:262\u001b[0m, in \u001b[0;36mGenerativeModel.generate_content\u001b[1;34m(self, contents, generation_config, safety_settings, stream, tools, tool_config, request_options)\u001b[0m\n\u001b[0;32m 261\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 262\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_client\u001b[38;5;241m.\u001b[39mgenerate_content(\n\u001b[0;32m 263\u001b[0m request,\n\u001b[0;32m 264\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mrequest_options,\n\u001b[0;32m 265\u001b[0m )\n\u001b[0;32m 266\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m generation_types\u001b[38;5;241m.\u001b[39mGenerateContentResponse\u001b[38;5;241m.\u001b[39mfrom_response(response)\n",
317
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\ai\\generativelanguage_v1beta\\services\\generative_service\\client.py:791\u001b[0m, in \u001b[0;36mGenerativeServiceClient.generate_content\u001b[1;34m(self, request, model, contents, retry, timeout, metadata)\u001b[0m\n\u001b[0;32m 790\u001b[0m \u001b[38;5;66;03m# Send the request.\u001b[39;00m\n\u001b[1;32m--> 791\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[43mrpc\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 792\u001b[0m \u001b[43m \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 793\u001b[0m \u001b[43m \u001b[49m\u001b[43mretry\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mretry\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 794\u001b[0m \u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtimeout\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 795\u001b[0m \u001b[43m \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmetadata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 796\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 798\u001b[0m \u001b[38;5;66;03m# Done; return the response.\u001b[39;00m\n",
318
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\api_core\\gapic_v1\\method.py:131\u001b[0m, in \u001b[0;36m_GapicCallable.__call__\u001b[1;34m(self, timeout, retry, compression, *args, **kwargs)\u001b[0m\n\u001b[0;32m 129\u001b[0m kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcompression\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m compression\n\u001b[1;32m--> 131\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m wrapped_func(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
319
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\api_core\\retry\\retry_unary.py:293\u001b[0m, in \u001b[0;36mRetry.__call__.<locals>.retry_wrapped_func\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 290\u001b[0m sleep_generator \u001b[38;5;241m=\u001b[39m exponential_sleep_generator(\n\u001b[0;32m 291\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_initial, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_maximum, multiplier\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_multiplier\n\u001b[0;32m 292\u001b[0m )\n\u001b[1;32m--> 293\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mretry_target\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 294\u001b[0m \u001b[43m \u001b[49m\u001b[43mtarget\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 295\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_predicate\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 296\u001b[0m \u001b[43m \u001b[49m\u001b[43msleep_generator\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 297\u001b[0m \u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_timeout\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 298\u001b[0m \u001b[43m \u001b[49m\u001b[43mon_error\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mon_error\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 299\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
320
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\api_core\\retry\\retry_unary.py:153\u001b[0m, in \u001b[0;36mretry_target\u001b[1;34m(target, predicate, sleep_generator, timeout, on_error, exception_factory, **kwargs)\u001b[0m\n\u001b[0;32m 151\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[0;32m 152\u001b[0m \u001b[38;5;66;03m# defer to shared logic for handling errors\u001b[39;00m\n\u001b[1;32m--> 153\u001b[0m \u001b[43m_retry_error_helper\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 154\u001b[0m \u001b[43m \u001b[49m\u001b[43mexc\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 155\u001b[0m \u001b[43m \u001b[49m\u001b[43mdeadline\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 156\u001b[0m \u001b[43m \u001b[49m\u001b[43msleep\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 157\u001b[0m \u001b[43m \u001b[49m\u001b[43merror_list\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 158\u001b[0m \u001b[43m \u001b[49m\u001b[43mpredicate\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 159\u001b[0m \u001b[43m \u001b[49m\u001b[43mon_error\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 160\u001b[0m \u001b[43m \u001b[49m\u001b[43mexception_factory\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 161\u001b[0m \u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 162\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 163\u001b[0m \u001b[38;5;66;03m# if exception not raised, sleep before next attempt\u001b[39;00m\n",
321
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\api_core\\retry\\retry_base.py:212\u001b[0m, in \u001b[0;36m_retry_error_helper\u001b[1;34m(exc, deadline, next_sleep, error_list, predicate_fn, on_error_fn, exc_factory_fn, original_timeout)\u001b[0m\n\u001b[0;32m 207\u001b[0m final_exc, source_exc \u001b[38;5;241m=\u001b[39m exc_factory_fn(\n\u001b[0;32m 208\u001b[0m error_list,\n\u001b[0;32m 209\u001b[0m RetryFailureReason\u001b[38;5;241m.\u001b[39mNON_RETRYABLE_ERROR,\n\u001b[0;32m 210\u001b[0m original_timeout,\n\u001b[0;32m 211\u001b[0m )\n\u001b[1;32m--> 212\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m final_exc \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01msource_exc\u001b[39;00m\n\u001b[0;32m 213\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m on_error_fn \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
322
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\api_core\\retry\\retry_unary.py:144\u001b[0m, in \u001b[0;36mretry_target\u001b[1;34m(target, predicate, sleep_generator, timeout, on_error, exception_factory, **kwargs)\u001b[0m\n\u001b[0;32m 143\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 144\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mtarget\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 145\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m inspect\u001b[38;5;241m.\u001b[39misawaitable(result):\n",
323
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\api_core\\timeout.py:120\u001b[0m, in \u001b[0;36mTimeToDeadlineTimeout.__call__.<locals>.func_with_timeout\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 118\u001b[0m kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtimeout\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mmax\u001b[39m(\u001b[38;5;241m0\u001b[39m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_timeout \u001b[38;5;241m-\u001b[39m time_since_first_attempt)\n\u001b[1;32m--> 120\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m func(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
324
+ "File \u001b[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\google\\api_core\\grpc_helpers.py:78\u001b[0m, in \u001b[0;36m_wrap_unary_errors.<locals>.error_remapped_callable\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 77\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m grpc\u001b[38;5;241m.\u001b[39mRpcError \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m---> 78\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exceptions\u001b[38;5;241m.\u001b[39mfrom_grpc_error(exc) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexc\u001b[39;00m\n",
325
+ "\u001b[1;31mInternalServerError\u001b[0m: 500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting",
326
+ "\nDuring handling of the above exception, another exception occurred:\n",
327
+ "\u001b[1;31mUnboundLocalError\u001b[0m Traceback (most recent call last)",
328
+ "Cell \u001b[1;32mIn[13], line 8\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i,t \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(data):\n\u001b[0;32m 7\u001b[0m \u001b[38;5;28mprint\u001b[39m(i)\n\u001b[1;32m----> 8\u001b[0m temp_answer, answer \u001b[38;5;241m=\u001b[39m \u001b[43mfull_chain_single_question\u001b[49m\u001b[43m(\u001b[49m\u001b[43mt\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mquestion\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 9\u001b[0m test_log\u001b[38;5;241m.\u001b[39mappend({\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdesired topic\u001b[39m\u001b[38;5;124m'\u001b[39m:t[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdesired\u001b[39m\u001b[38;5;124m'\u001b[39m],\n\u001b[0;32m 10\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mquestion\u001b[39m\u001b[38;5;124m'\u001b[39m:t[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mquestion\u001b[39m\u001b[38;5;124m'\u001b[39m],\n\u001b[0;32m 11\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfirst answer\u001b[39m\u001b[38;5;124m'\u001b[39m:temp_answer,\n\u001b[0;32m 12\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfinal answer\u001b[39m\u001b[38;5;124m'\u001b[39m:answer})\n\u001b[0;32m 13\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtest_results.json\u001b[39m\u001b[38;5;124m\"\u001b[39m,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m outfile:\n",
329
+ "Cell \u001b[1;32mIn[9], line 16\u001b[0m, in \u001b[0;36mfull_chain_single_question\u001b[1;34m(input_prompt)\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 15\u001b[0m \u001b[38;5;28mprint\u001b[39m(e)\n\u001b[1;32m---> 16\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mtemp_answer\u001b[49m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mError occured: \u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;28mstr\u001b[39m(e)\n",
330
+ "\u001b[1;31mUnboundLocalError\u001b[0m: local variable 'temp_answer' referenced before assignment"
331
+ ]
332
+ }
333
+ ],
334
+ "source": [
335
+ "with open(\"test_questions.txt\",\"r\") as infile:\n",
336
+ " data = json.load(infile)\n",
337
+ "print(data[0])\n",
338
+ "\n",
339
+ "test_log = []\n",
340
+ "for i,t in enumerate(data):\n",
341
+ " print(i)\n",
342
+ " temp_answer, answer = full_chain_single_question(t['question'])\n",
343
+ " test_log.append({'desired topic':t['desired'],\n",
344
+ " 'question':t['question'],\n",
345
+ " 'first answer':temp_answer,\n",
346
+ " 'final answer':answer})\n",
347
+ "with open(\"test_results.json\",\"w\") as outfile:\n",
348
+ " json.dump(test_log,outfile)"
349
+ ]
350
+ }
351
+ ],
352
+ "metadata": {
353
+ "kernelspec": {
354
+ "display_name": "Python 3",
355
+ "language": "python",
356
+ "name": "python3"
357
+ },
358
+ "language_info": {
359
+ "codemirror_mode": {
360
+ "name": "ipython",
361
+ "version": 3
362
+ },
363
+ "file_extension": ".py",
364
+ "mimetype": "text/x-python",
365
+ "name": "python",
366
+ "nbconvert_exporter": "python",
367
+ "pygments_lexer": "ipython3",
368
+ "version": "3.10.11"
369
+ }
370
+ },
371
+ "nbformat": 4,
372
+ "nbformat_minor": 2
373
+ }
test_questions.txt ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [{
2
+ "desired": "Natural Language Processing (Computer Science)",
3
+ "question": "What are some recent papers on deep learning architectures for text classification, and can you recommend any surveys or reviews on the topic?"
4
+ },
5
+ {
6
+ "desired": "Power System Stability (Electronics Engineering)",
7
+ "question": "Can you suggest some key papers on transient stability analysis in power systems, and are there any recent reviews on the impact of renewable energy sources on grid stability?"
8
+ },
9
+ {
10
+ "desired": "International Trade (Economics)",
11
+ "question": "What are some influential papers on the effects of trade agreements on economic growth, and are there any recent studies on the impact of globalization on income inequality?"
12
+ },
13
+ {
14
+ "desired": "Machine Learning for Healthcare (Computer Science)",
15
+ "question": "Can you recommend some papers on the application of machine learning to medical diagnosis, and are there any recent reviews on the use of deep learning in healthcare?"
16
+ },
17
+ {
18
+ "desired": "Cryptography (Computer Science)",
19
+ "question": "What are some recent papers on post-quantum cryptography, and are there any surveys on the current state of quantum-resistant algorithms?"
20
+ },
21
+ {
22
+ "desired": "Control Systems (Electronics Engineering)",
23
+ "question": "Can you suggest some key papers on model predictive control for nonlinear systems, and are there any recent reviews on the application of control theory to robotics?"
24
+ },
25
+ {
26
+ "desired": "Macroeconomic Modeling (Economics)",
27
+ "question": "What are some influential papers on the use of Bayesian methods in macroeconomic modeling, and are there any recent studies on the impact of monetary policy on economic growth?"
28
+ },
29
+ {
30
+ "desired": "Computer Vision (Computer Science)",
31
+ "question": "Can you recommend some papers on object detection using convolutional neural networks, and are there any recent reviews on the application of computer vision to autonomous vehicles?"
32
+ },
33
+ {
34
+ "desired": "Power Electronics (Electronics Engineering)",
35
+ "question": "What are some recent papers on the design of high-frequency power converters, and are there any surveys on the application of power electronics to renewable energy systems?"
36
+ },
37
+ {
38
+ "desired": "Game Theory (Mathematics)",
39
+ "question": "Can you suggest some key papers on the application of game theory to network economics, and are there any recent reviews on the use of game theory to model strategic decision-making?"
40
+ }]
test_results.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "desired topic": "Natural Language Processing (Computer Science)",
4
+ "question": "What are some recent papers on deep learning architectures for text classification, and can you recommend any surveys or reviews on the topic?",
5
+ "first answer": "{\n \"keywords\": [\n \"Deep Learning\",\n \"Text Classification\",\n \"Architectures\",\n \"Natural Language Processing\"\n ],\n \"description\": \"Deep learning architectures have achieved state-of-the-art results on a wide range of text classification tasks. These architectures typically consist of multiple layers of artificial neural networks, which are trained on large datasets of labeled text. Some of the most popular deep learning architectures for text classification include convolutional neural networks (CNNs), recurrent neural networks (RNNs), and transformers. CNNs are particularly well-suited for tasks that involve extracting local features from text, such as sentiment analysis and spam detection. RNNs are well-suited for tasks that involve processing sequential data, such as machine translation and text summarization. Transformers are a relatively new type of deep learning architecture that has shown promising results on a variety of text classification tasks. Transformers are particularly well-suited for tasks that involve long-range dependencies, such as question answering and named entity recognition.\"\n}",
6
+ "final answer": "Sure, here are some recent papers on deep learning architectures for text classification:\n\n- [Text Classification Algorithms: A Survey](http://arxiv.org/pdf/1904.08067v5) by Kamran Kowsari, Kiana Jafari Meimandi, Mojtaba Heidarysafa, Sanjana Mendu, Laura E. Barnes, and Donald E. Brow\n- [A survey of neural models for the automatic analysis of conversation: Towards a better integration of the social sciences](http://arxiv.org/pdf/2203.16891v1) by Chlo\u00e9 Clavel, Matthieu Labeau, and Justine Cassel\n- [Text-based Sentiment Analysis and Music Emotion Recognition](http://arxiv.org/pdf/1810.03031v1) by Erion \u00c7an\n\nThese papers provide a comprehensive overview of the current state-of-the-art in deep learning architectures for text classification.\n\nIn addition to these papers, I would also recommend the following surveys and reviews on the topic:\n\n- [A Survey on Deep Learning for Text Classification](https://arxiv.org/abs/2107.13036) by Yequan Wang, Minlie Huang, Xiaoyan Zhu, and Li Zhao\n- [Deep Learning for Text Classification: A Comprehensive Review](https://arxiv.org/abs/2004.03284) by Xiang Zhang, Junbo Zhao, and Yann LeCun\n- [Text Classification with Deep Learning: A Survey](https://arxiv.org/abs/1909.07894) by Yiming Yang, Zhiyong Tan, and Xiaojun Wan\n\nThese surveys and reviews provide a more in-depth look at the different deep learning architectures that have been used for text classification, as well as their strengths and weaknesses."
7
+ },
8
+ {
9
+ "desired topic": "Power System Stability (Electronics Engineering)",
10
+ "question": "Can you suggest some key papers on transient stability analysis in power systems, and are there any recent reviews on the impact of renewable energy sources on grid stability?",
11
+ "first answer": "{\n \"keywords\": [\"Transient stability analysis\", \"Power systems\", \"Renewable energy sources\", \"Grid stability\", \"Reviews\"],\n \"description\": \"Transient stability analysis is a technique used to assess the ability of a power system to maintain stable operation following a disturbance. It is used to ensure that the system can withstand sudden changes in load or generation, such as those caused by faults or the addition of renewable energy sources. Recent reviews have investigated the impact of renewable energy sources on grid stability, and have found that they can pose challenges to the stability of the system. This is due to the intermittent nature of renewable energy sources, which can cause fluctuations in the power supply. As a result, it is important to develop new methods for transient stability analysis that can take into account the impact of renewable energy sources.\"\n}",
12
+ "final answer": "I'm sorry, but I cannot find any records related to transient stability analysis in power systems or the impact of renewable energy sources on grid stability in your database. However, I can recommend some other related resources that you may find helpful:\n\n1. IEEE Transactions on Power Systems: https://ieeexplore.ieee.org/browse/publications/title/tpwrs\n2. International Journal of Electrical Power & Energy Systems: https://www.sciencedirect.com/journal/international-journal-of-electrical-power-and-energy-systems\n3. Electric Power Systems Research: https://www.sciencedirect.com/journal/electric-power-systems-research"
13
+ },
14
+ {
15
+ "desired topic": "International Trade (Economics)",
16
+ "question": "What are some influential papers on the effects of trade agreements on economic growth, and are there any recent studies on the impact of globalization on income inequality?",
17
+ "first answer": "{\n \"keywords\": [\"Trade agreements\", \"Economic growth\", \"Globalization\", \"Income inequality\"],\n \"description\": \"Trade agreements are agreements between two or more countries that reduce or eliminate trade barriers, such as tariffs and quotas. Economic growth is the increase in the value of goods and services produced by an economy over time. Globalization is the process of increasing interdependence among countries through the exchange of goods, services, and ideas. Income inequality is the uneven distribution of income across a population.\"\n}",
18
+ "final answer": "Sure, here are some influential papers on the effects of trade agreements on economic growth:\n\n* [The Economic Effects of Trade](https://www.brookings.edu/wp-content/uploads/2016/06/06_trade_bernard_busse.pdf) by Andrew B. Bernard and Meghan R. Busse\n* [Trade and Economic Growth](https://www.imf.org/external/pubs/ft/fandd/2001/12/gupta.htm) by Sanjeev Gupta, Shang-Jin Wei, and Elena Zubovich\n* [The Impact of Trade on Economic Growth: A Meta-Analysis](https://www.sciencedirect.com/science/article/abs/pii/S0923792914000719?via%3Dihub) by David Greenaway, W. Robert C. F. Ramirez, and Heng-fu Zou\n\nHere are some recent studies on the impact of globalization on income inequality:\n\n* [Globalization and Income Inequality](https://www.imf.org/external/pubs/ft/fandd/2016/03/gupta.htm) by Sanjeev Gupta, Carlo Perroni, and Joel S. Shin\n* [The Impact of Globalization on Income Inequality: A Review of the Evidence](https://voxeu.org/article/impact-globalization-income-inequality-review-evidence) by Branko Milanovic\n* [Globalization, Inequality, and the Middle Class](https://www.piie.com/publications/piie-charts/globalization-inequality-and-middle-class) by Adam S. Posen\n\nThese are just a few examples of the many studies that have been conducted on the effects of trade agreements and globalization on economic growth and income inequality. I hope this information is helpful. Please let me know if you have any other questions."
19
+ },
20
+ {
21
+ "desired topic": "Machine Learning for Healthcare (Computer Science)",
22
+ "question": "Can you recommend some papers on the application of machine learning to medical diagnosis, and are there any recent reviews on the use of deep learning in healthcare?",
23
+ "first answer": "{\n \"keywords\": [\n \"Machine learning\",\n \"Medical diagnosis\",\n \"Deep learning\",\n \"Healthcare\"\n ],\n \"description\": \"Machine learning is a rapidly growing field that has the potential to revolutionize many industries, including healthcare. Machine learning algorithms can be used to identify patterns and make predictions, which can be used to improve the accuracy and efficiency of medical diagnosis. Deep learning is a type of machine learning that uses artificial neural networks to learn from data. Deep learning algorithms have been shown to be very effective at tasks such as image recognition and natural language processing, and they are now being used to develop new medical applications. Some recent reviews on the use of deep learning in healthcare include: \\n\\n - [Deep Learning in Healthcare: A Review](https://arxiv.org/abs/1809.09734) \\n\\n - [Deep Learning for Healthcare: A Comprehensive Review](https://arxiv.org/abs/1906.02196) \\n\\n - [Deep Learning in Medical Image Analysis: A Review](https://arxiv.org/abs/1812.09170)\"\n}",
24
+ "final answer": "Certainly! I have found some papers that may be of interest to you on the application of machine learning to medical diagnosis. Here are a few examples:\n\n - \"Deep Learning and Health Informatics for Smart Monitoring and Diagnosis\" by Amin Gasm: http://arxiv.org/pdf/2208.03143v1\n - \"Classification of Alzheimer's Disease Structural MRI Data by Deep Learning Convolutional Neural Networks\" by Saman Sarraf and Ghassem Tofigh: http://arxiv.org/pdf/1607.06583v2\n\n I was unable to find any recent reviews on the use of deep learning in healthcare. However, I did find a few articles that may be of interest:\n\n - \"A Systematic Review of Deep Graph Neural Networks: Challenges, Classification, Architectures, Applications & Potential Utility in Bioinformatics\" by Adil Mudasir Malla and Asif Ali Bank: http://arxiv.org/pdf/2311.02127v1\n\n I hope this information is helpful. Please let me know if you have any other questions."
25
+ },
26
+ {
27
+ "desired topic": "Cryptography (Computer Science)",
28
+ "question": "What are some recent papers on post-quantum cryptography, and are there any surveys on the current state of quantum-resistant algorithms?",
29
+ "first answer": "{\n \"keywords\": [\n \"Post-quantum cryptography\",\n \"Quantum-resistant algorithms\",\n \"Lattice-based cryptography\",\n \"Code-based cryptography\",\n \"Multivariate cryptography\"\n ],\n \"description\": \"Post-quantum cryptography (PQC) is a branch of cryptography that studies cryptographic algorithms that are resistant to attacks by quantum computers. Quantum computers are computers that use the principles of quantum mechanics to perform calculations. Quantum computers are much more powerful than classical computers, and they could potentially break many of the cryptographic algorithms that are currently used to protect data. PQC algorithms are designed to be resistant to attacks by quantum computers. There are a number of different PQC algorithms, including lattice-based cryptography, code-based cryptography, and multivariate cryptography. Lattice-based cryptography is based on the hardness of solving certain problems in lattice theory. Code-based cryptography is based on the hardness of decoding certain types of codes. Multivariate cryptography is based on the hardness of solving certain types of multivariate equations.\"\n}",
30
+ "final answer": "Error occured: object of type 'NoneType' has no len()"
31
+ },
32
+ {
33
+ "desired topic": "Control Systems (Electronics Engineering)",
34
+ "question": "Can you suggest some key papers on model predictive control for nonlinear systems, and are there any recent reviews on the application of control theory to robotics?",
35
+ "first answer": "{\n \"keywords\": [\"Model Predictive Control\", \"Nonlinear Systems\", \"Robotics\", \"Control Theory\"],\n \"description\": \"Model predictive control (MPC) is a powerful control technique that has been successfully applied to a wide range of nonlinear systems. MPC is based on the idea of predicting the future behavior of a system and then using this prediction to optimize the control inputs. This approach can be used to achieve a variety of control objectives, such as stability, performance, and robustness.\n\nIn recent years, there has been a growing interest in the application of control theory to robotics. This is due to the fact that robots are becoming increasingly complex and are being used in a wider range of applications. Control theory provides a powerful framework for designing and analyzing robotic systems. It can be used to ensure that robots are stable, perform well, and are robust to disturbances.\n\nThere are a number of excellent resources available on the topic of model predictive control for nonlinear systems and the application of control theory to robotics. Some of these resources include:\n\n* **Model Predictive Control for Nonlinear Systems** by Alberto Bemporad and Manfred Morari\n* **Control of Robot Manipulators** by Mark W. Spong, Seth Hutchinson, and M. Vidyasagar\n* **Robotics, Vision and Control** by Peter Corke\"\n}",
36
+ "final answer": "Sure, here are some key papers on model predictive control for nonlinear systems:\n\n* [Model Predictive Control for Nonlinear Systems](https://www.sciencedirect.com/science/article/abs/pii/S0005109816303182) by J.B. Rawlings, D.Q. Mayne, and M.M. Diehl\n* [Nonlinear Model Predictive Control: Theory and Algorithms](https://link.springer.com/book/10.1007/978-0-85729-312-7) by L. Gr\u00fcne and J. Pannek\n* [Model Predictive Control of Nonlinear Systems: A Survey](https://ieeexplore.ieee.org/document/904558) by D.Q. Mayne, J.B. Rawlings, C.V. Rao, and P.O.M. Scokaert\n\nAs for recent reviews on the application of control theory to robotics, here are a few:\n\n* [Control of Robot Manipulators in Joint Space](https://link.springer.com/article/10.1007/s10956-019-09771-9) by F. Flacco, E. De Momi, and M. Gabiccini\n* [Control Techniques for Robotic Manipulators](https://ieeexplore.ieee.org/document/7985705) by R. Kelly, V. Santib\u00e1\u00f1ez, and A. Loria\n* [Recent Advances in Control Techniques for Robots](https://www.mdpi.com/2076-3417/11/1/12/htm) by M.H. Ang, P.Y. Oh, and A.A. Goldenberg\n\nI hope this helps!"
37
+ },
38
+ {
39
+ "desired topic": "Macroeconomic Modeling (Economics)",
40
+ "question": "What are some influential papers on the use of Bayesian methods in macroeconomic modeling, and are there any recent studies on the impact of monetary policy on economic growth?",
41
+ "first answer": "{\n \"keywords\": [\n \"Bayesian methods\",\n \"Macroeconomic modeling\",\n \"Monetary policy\",\n \"Economic growth\"\n ],\n \"description\": \"Bayesian methods are a powerful tool for macroeconomic modeling. They allow economists to incorporate uncertainty into their models and to make inferences about the parameters of those models. This can lead to more accurate and reliable forecasts. In recent years, there has been a growing interest in the use of Bayesian methods to study the impact of monetary policy on economic growth. Several studies have found that Bayesian methods can provide valuable insights into this relationship.\"\n}",
42
+ "final answer": "Sure, here are some influential papers on the use of Bayesian methods in macroeconomic modeling:\n\n1. **[Dimensional Analysis in Economics: A Study of the Neoclassical Economic Growth Model](http://arxiv.org/pdf/1802.10528v1)** by Miguel Alvarez Texocotitla, M. David Alvarez Hernandez, and Shani Alvarez Hernande\n2. **[Bayesian state-space modeling for analyzing heterogeneous network effects of US monetary policy](http://arxiv.org/pdf/1911.06206v3)** by Niko Hauzenberger and Michael Pfarrhofe\n3. **[Theory coherent shrinkage of Time-Varying Parameters in VARs](http://arxiv.org/pdf/2311.11858v1)** by Andrea Renzett\n\nThese papers provide a good overview of the current state of the art in Bayesian macroeconomic modeling.\n\nAs for recent studies on the impact of monetary policy on economic growth, here are a few examples:\n\n1. **[The Impact of Monetary Policy on Economic Growth: A Survey of the Literature](https://www.imf.org/external/pubs/ft/fandd/2019/03/gupta.htm)** by Sanjeev Gupta, Gita Gopinath, Era Dabla-Norris, and Davide Furceri\n2. **[Monetary Policy and Economic Growth](https://www.bis.org/publ/work469.pdf)** by Hyun Song Shin\n3. **[The Impact of Monetary Policy on Economic Growth: A Meta-Analysis](https://www.sciencedirect.com/science/article/abs/pii/S1053482720300683)** by Michael Dotsey and Robert G. King\n\nThese studies provide a mixed bag of results, with some finding that monetary policy has a positive impact on economic growth, while others find that it has a negative impact. The overall consensus seems to be that the impact of monetary policy on economic growth is complex and depends on a variety of factors, such as the country's economic conditions and the specific monetary policy tools used.\n\nI hope this information is helpful. Please let me know if you have any other questions."
43
+ },
44
+ {
45
+ "desired topic": "Computer Vision (Computer Science)",
46
+ "question": "Can you recommend some papers on object detection using convolutional neural networks, and are there any recent reviews on the application of computer vision to autonomous vehicles?",
47
+ "first answer": "{\n \"keywords\": [\"object detection\", \"convolutional neural networks\", \"computer vision\", \"autonomous vehicles\"],\n \"description\": \"Object detection is a fundamental task in computer vision that involves identifying and localizing objects of interest in images or videos. Convolutional Neural Networks (CNNs) have emerged as a powerful tool for object detection, achieving state-of-the-art results on various datasets. On the other hand, computer vision plays a vital role in the development of autonomous vehicles, enabling them to perceive and understand their surroundings, including object detection, lane detection, and traffic sign recognition. Recent reviews on the application of computer vision to autonomous vehicles provide comprehensive overviews of the latest advancements and challenges in this rapidly evolving field.\"\n}",
48
+ "final answer": "Error occured: The `response.text` quick accessor only works when the response contains a valid `Part`, but none was returned. Check the `candidate.safety_ratings` to see if the response was blocked."
49
+ },
50
+ {
51
+ "desired topic": "Power Electronics (Electronics Engineering)",
52
+ "question": "What are some recent papers on the design of high-frequency power converters, and are there any surveys on the application of power electronics to renewable energy systems?",
53
+ "first answer": "{\n \"keywords\": [\"Power Converter\", \"High-Frequency\", \"Renewable Energy\", \"Power Electronics\"],\n \"description\": \"Power converters are essential components in many electronic systems, and their design is critical to the overall performance of the system. High-frequency power converters are becoming increasingly popular due to their advantages in terms of size, weight, and efficiency. Recent advances in power electronics technology have made it possible to design high-frequency power converters with very high efficiency and power density.\n\nPower electronics is also playing an increasingly important role in renewable energy systems. Renewable energy sources, such as solar and wind power, are intermittent and variable, and power electronics is used to convert and store this energy in a form that can be used by the grid.\n\nThere are a number of recent surveys on the application of power electronics to renewable energy systems. These surveys provide a comprehensive overview of the current state of the art in this field, and they can be a valuable resource for researchers and engineers working in this area.\"\n}",
54
+ "final answer": "I'm sorry, but I could not find any recent papers on the design of high-frequency power converters in my database. However, I found several papers related to the application of power electronics to renewable energy systems. Would you like me to share those with you?"
55
+ },
56
+ {
57
+ "desired topic": "Game Theory (Mathematics)",
58
+ "question": "Can you suggest some key papers on the application of game theory to network economics, and are there any recent reviews on the use of game theory to model strategic decision-making?",
59
+ "first answer": "```JSON\n{\n \"keywords\": [\n \"Game Theory\",\n \"Network Economics\",\n \"Strategic Decision-Making\",\n \"Modeling\"\n ],\n \"description\": \"Game theory is a branch of mathematics that studies strategic decision-making in situations where multiple agents interact. It has been applied to a wide range of fields, including network economics. Network economics is the study of the economic behavior of telecommunications networks and the Internet. Game theory can be used to model the strategic interactions between different network operators, service providers, and users. This can help to understand how these interactions affect the performance of networks and the prices of network services. Recent reviews on the use of game theory to model strategic decision-making include: \\n\\n1. \\\"Game Theory and Network Economics\\\" by F. Kelly, A. Mauleon, and D. Tan (2016)\\n2. \\\"Game Theory in Network Economics\\\" by T. Roughgarden (2016)\\n3. \\\"A Survey of Game Theory in Network Economics\\\" by M. Osborne and A. Rubinstein (2017)\"\n}\n```",
60
+ "final answer": "Sure, here are some key papers on the application of game theory to network economics:\n\n* [Mathematics of multi-agent learning systems at the interface of game theory and artificial intelligence](http://arxiv.org/pdf/2403.07017v1) by Long Wang, Feng Fu, Xingru Che\n* [On a Connection between Differential Games, Optimal Control, and Energy-based Models for Multi-Agent Interactions](http://arxiv.org/pdf/2308.16539v2) by Christopher Diehl, Tobias Klosek, Martin Kr\u00fcger, Nils Murzyn, Torsten Bertra\n* [Game Theoretic Rating in N-player general-sum games with Equilibria](http://arxiv.org/pdf/2210.02205v1) by Luke Marris, Marc Lanctot, Ian Gemp, Shayegan Omidshafiei, Stephen McAleer, Jerome Connor, Karl Tuyls, Thore Graepe\n\nIn addition to these papers, there are a number of recent reviews on the use of game theory to model strategic decision-making. Here are a few examples:\n\n* [Game Theory and Network Economics](https://www.researchgate.net/publication/228887562_Game_Theory_and_Network_Economics) by Anna Nagurney\n* [Game Theory in Network Economics](https://EconPapers.repec.org/RePEc:eee:ecbull:v:21:y:2019:i:1:p:125-142) by Jordi Mass\u00f3 and Vincent ND Noumba\n* [The Application of Game Theory to Network Economics](https://link.springer.com/article/10.1007/s10902-018-9433-1) by Vincent ND Noumba\n\nI hope this information is helpful. Please let me know if you have any other questions."
61
+ }
62
+ ]
topic_descriptions.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "computer science":"Computer Science: The Language of Machines. Focus: This field deals with the theory, design, development, and application of software and hardware systems. It delves into the creation of algorithms, data structures, and programming languages that enable computers to process information and solve problems. Core Concepts: Algorithms: Step-by-step instructions for computers to solve problems. Data Structures: Organized ways to store and access data efficiently. Programming Languages: Tools to communicate instructions to computers. Artificial Intelligence: Machines mimicking human-like intelligence. Machine Learning: Algorithms that learn from data without explicit programming. Applications: From designing websites and mobile apps to developing complex operating systems and artificial intelligence, computer science underpins the digital world we interact with daily.",
3
+ "economics":"Economics: The Science of Choice and Exchange. Focus: Economics examines how individuals, societies, and governments make choices in a world with scarce resources. It analyzes production, distribution, and consumption of goods and services, studying factors like market behavior, prices, and money. Core Concepts: Scarcity: Limited resources versus unlimited wants and needs. Supply and Demand: Forces that determine market prices. Rational Choice Theory: Individuals making choices based on their preferences and constraints. Macroeconomics: Economy-wide phenomena like inflation, unemployment, and economic growth. Microeconomics: Individual and firm behavior in markets. Applications: Economic principles are used to understand market trends, formulate effective government policies, design financial systems, and make informed investment decisions.",
4
+ "electrical engineering and system science":"Electrical Engineering & System Science: Bridging Power and Complexity. Focus: This interdisciplinary field combines electrical engineering, which deals with electricity, electronics, and electromagnetism, with system science, which focuses on analyzing and designing complex systems. It involves designing and developing electrical circuits, devices, and systems for power generation, transmission, control, and communication. Core Concepts: Circuits: Networks of electrical components like resistors, capacitors, and transistors. Electromagnetism: Interaction of electric and magnetic fields. Power Systems: Networks for generating, transmitting, and distributing electricity. Control Systems: Systems that regulate the behavior of other systems. Signals and Systems: Analysis of how information is represented and processed in electrical systems. Applications: Electrical engineers and system scientists create a vast array of technologies, from power grids and communication systems to medical devices and embedded systems in everyday gadgets.",
5
+ "mathematics":"Mathematics: The Universal Language of Science. Focus: Mathematics is the abstract study of numbers, quantity, relationships, structures, and patterns. It provides a foundation for many other disciplines by offering a language and tools to express ideas, model problems, and derive solutions. Core Concepts: Calculus: Branch of mathematics dealing with rates of change and accumulation. Algebra: Studying relationships between variables using symbols and operations. Geometry: Properties of shapes and spaces. Probability and Statistics: Analyzing randomness and drawing meaningful conclusions from data. Logic: Reasoning and making valid deductions from given statements. Applications: Mathematics is an indispensable tool in all scientific fields, from physics and engineering to economics and computer science. It is also used in finance, cryptography, and game theory."
6
+ }