|
39 | 39 | % Extract individual paper entries from the API response and use ChatGPT |
40 | 40 | % to determine whether each paper is related to the specified topic. |
41 | 41 |
|
42 | | -pattern = '<entry>(.*?)</entry>'; |
43 | | - |
44 | 42 | % ChatGPT will parse the XML file, so we only need to extract the relevant |
45 | 43 | % entries. |
46 | | -matches = regexp(code, pattern, 'tokens'); |
| 44 | +entries = extractBetween(code, '<entry>', '</entry>'); |
47 | 45 |
|
48 | 46 | % Determine the topic of interest |
49 | 47 | topic = "Embedding documents or sentences"; |
50 | 48 |
|
51 | 49 | % Loop over the entries and see if they are relevant to the topic of |
52 | 50 | % interest. |
53 | | -for i = 1:length(matches) |
| 51 | +for i = 1:length(entries) |
54 | 52 | prompt = "Given the following paper:" + newline +... |
55 | | - string(matches{i})+ newline +... |
| 53 | + string(entries{i})+ newline +... |
56 | 54 | "Is it related to the topic: "+ topic +"?" + ... |
57 | 55 | " Answer 'yes' or 'no'."; |
58 | 56 | [text, response] = generate(chat, prompt); |
59 | 57 |
|
60 | 58 | % If the model classifies this entry as relevant, then it tries to |
61 | 59 | % request a function call. |
62 | 60 | if contains("yes", text, IgnoreCase=true) |
63 | | - prompt = "Given the following paper:" + newline + string(matches{i})+ newline +... |
| 61 | + prompt = "Given the following paper:" + newline + string(entries{i})+ newline +... |
64 | 62 | "Given the topic: "+ topic + newline + "Write the details to a table."; |
65 | 63 | [text, response] = generate(chat, prompt); |
66 | 64 |
|
|
0 commit comments