Skip to content

myoshioka/openapi-embeddings-based-search-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample of using OpenAI GPT API with embeddings

Overview

  • This repository is a sample code based on openapi's examples pages
  • The content is the same, but we have made it possible to search in Japanese by using data from the Japanese Wikipedia site.

Description

  • Embeddings are created by retrieving data from the Japanese Wikipedia site. Please refer to the Openapi site for details.

Getting Started

  • Install the library with poetry.
$ poetry  install
  • Create an env file and set the API key.
$ touch .env

# Edit env file
OPENAI_API_KEY=****************
  • Creates a data set. When completed, a csv file of winter_olympics_2022_jp.csv will be saved.(It will take a few minutes to complete.)
$ poetry run python dataset.py
  • Ask a question with the openapi API. First, the results of the question without embeddings are displayed. Next, the results using the embeddings you created are displayed.
$ poetry run python main.py
  • It is displayed like this.The first answer is incorrect; the second is correct.
# Question
2022年の北京オリンピックで男子スノーボードハーフパイプの金メダルをもらった選手は誰ですか?

# Results of the question without embeddings
2022年の北京オリンピックはまだ開催されていないため、男子スノーボードハーフパイプの金メダリストはまだ決まっていません。

# Results using the embeddings
2022年の北京オリンピックで男子スノーボードハーフパイプの金メダルをもらった選手は平野歩夢です。

About

Sample of using OpenAI GPT API with embeddings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages