Skip to content

Commit

Permalink
📝 update readme for google search
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannLai committed Jan 23, 2024
1 parent f9bf0f0 commit 780374d
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,43 @@ if (response.data.choices[0].finish_reason === "function_call") {
}
```
<details><summary>Full example code about import { GoogleCustomSearch } from 'openai-function-calling-tools';
</summary>
Just 3 steps to use the tools in your OpenAI API project.
<p>
### Example 2: Function Calls with Google Custom Search
> 📝 Note: You need to apply for a Google Custom Search API key and a Google Custom Search Engine ID to use this tool.
#### The following is a sequence diagram of the example
```mermaid
sequenceDiagram
participant U as User
participant M as Main Function
participant O as OpenAI API
participant F as Functions Object
participant GC as Google Custom Search
U->>M: Execute main function
M->>M: Initialize configuration and API
M->>M: Define QUESTION variable
M->>M: Create Google Custom Search tool
M->>F: Add tool to functions object
loop Chat Completion Loop
M->>O: Request chat completion
O-->>M: Return response
alt If finish reason is "stop"
M->>U: Display answer and exit loop
else If finish reason is "function_call"
M->>M: Parse function call name and arguments
M->>F: Invoke corresponding function
F->>GC: Perform Google Custom Search
GC-->>F: Return search results
F->>M: Receive function result
M->>M: Add result to message queue
M->>M: Output function call details
else Other cases
M->>M: Continue loop
end
end
```
#### Code
```js
const { Configuration, OpenAIApi } = require("openai");
Expand Down Expand Up @@ -214,10 +247,8 @@ const main = async () => {
main();
```
</p>
</details>
### Example 2: Schema Extraction
### Example 3: Schema Extraction
Example to extract schema from a function call
Expand Down

0 comments on commit 780374d

Please sign in to comment.