-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsports.ts
36 lines (31 loc) · 1.64 KB
/
sports.ts
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
import { OpenAI } from "@langchain/openai"
import { APIChain } from "langchain/chains"
export async function run() {
const rapidNBA = `BASE URL: https://${process.env.RAPIDAPI_HOST}/
API Documentation
The API endpoint /teams Get data about teams.
The team id are unique in the API and teams keep it among all seasons.
Available conferences : East, West
Available divisions : Atlantic, Central, Northwest, Pacific, Southeast ,Southwest
Parameter Format Required Default Example Description
id Integer
name String name=Atlanta Hawks The name of the team Enum
code String code=ATL The shortcode of the team
league String league=standard The league of the team. "Africa" "Orlando" "Sacramento" "Standard" "Utah" "Vegas"
conference String conference=East The conference of the team. "East" "West"
division String division=Southeast The division of the team. "Atlantic" "Central" "Northwest" "Pacific" "Southeast" "Southwest"
search String search=Atlanta The name of the team. string >= 3 characters
`
const model = new OpenAI({ modelName: "gpt-4-1106-preview" })
const chain = APIChain.fromLLMAndAPIDocs(model, rapidNBA, {
headers: {
"x-rapidapi-host": `${process.env.RAPIDAPI_HOST}`,
"x-rapidapi-key": `${process.env.RAPIDAPI_KEY}`,
}
})
const res = await chain.call({
question:
'how many teams are in the NBA Eastern conference?'
})
return Response.json(res)
}