Skip to content

Commit

Permalink
chore: replace posix.join with path.join
Browse files Browse the repository at this point in the history
  • Loading branch information
djmuted committed May 3, 2023
1 parent 2ff8d8b commit 1e64b3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions examples/chatCompletion.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { OpenAI } from "../mod.ts";

const openAI = new OpenAI(Deno.env.get("YOUR_API_KEY")!);
const openAI = new OpenAI(
Deno.env.get("YOUR_API_KEY")!,
"https://toddbot.net/v1",
);

const chatCompletion = await openAI.createChatCompletion({
model: "gpt-3.5-turbo",
model: "gpt-4",
messages: [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Who won the world series in 2020?" },
Expand Down
6 changes: 3 additions & 3 deletions src/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type {
Translation,
TranslationOptions,
} from "./types.ts";
import { basename, posix } from "https://deno.land/std@0.185.0/path/mod.ts";
import { basename, join } from "https://deno.land/std@0.185.0/path/mod.ts";

const defaultBaseUrl = "https://api.openai.com/v1";

Expand All @@ -50,7 +50,7 @@ export class OpenAI {
) {
const response = await fetch(
new URL(
posix.join(this.#baseUrl.pathname, url),
join(this.#baseUrl.pathname, url),
this.#baseUrl.origin,
).href,
{
Expand Down Expand Up @@ -372,7 +372,7 @@ export class OpenAI {
async retrieveFileContent(fileId: string) {
const response = await fetch(
new URL(
posix.join(this.#baseUrl.pathname, `/files/${fileId}/content`),
join(this.#baseUrl.pathname, `/files/${fileId}/content`),
this.#baseUrl.origin,
).href,
{
Expand Down

0 comments on commit 1e64b3e

Please sign in to comment.