Last active
December 28, 2024 13:43
Revisions
-
uratmangun revised this gist
Dec 28, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export async function searchParser(content) { messages: [ { role: "system", content: "You're search results parser. You're given a search results HTML page and you're tasked with parsing the results and returning a json array of objects with the following fields: title, url, description." }, {role: "user", content} ] -
uratmangun revised this gist
Dec 28, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export async function searchParser(content) { messages: [ { role: "system", content: "You're search results parser. You're given a search results HTML page and you're tasked with parsing the results and returning a json array of objects with the following fields: title and url." }, {role: "user", content} ] -
uratmangun revised this gist
Dec 28, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export async function searchParser(content) { messages: [ { role: "system", content: "You're search results parser. You're given a search results HTML page and you're tasked with parsing the results and returning a json array of objects with the following fields: title, url, description." }, {role: "user", content} ] -
uratmangun created this gist
Dec 28, 2024 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ import OpenAI from "openai" import dotenv from 'dotenv'; import { zodResponseFormat } from "openai/helpers/zod"; import { z } from "zod"; dotenv.config({ path: '.env.local' }); const openai = new OpenAI({ baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/", apiKey: process.env.GEMINI_API_KEY }) const SearchResult = z.array( z.object({ title: z.string(), url: z.string(), description: z.string(), }) ); export async function searchParser(content) { const completion = await openai.chat.completions.create({ model: "gemini-2.0-flash-exp", response_format: zodResponseFormat(SearchResult, "search_result"), messages: [ { role: "system", content: "You're results parser. You're given a results HTML page and you're tasked with parsing the results and returning a json array of objects with the following fields: title, url, description." }, {role: "user", content} ] }) return completion }