mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-24 21:51:34 +10:00
Adding Ollama Support
This commit is contained in:
@ -3,6 +3,8 @@
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
import { openai } from "./client";
|
||||
import { useOpenAiStore } from "@/client/stores/openai";
|
||||
import { DEFAULT_MAX_TOKENS, DEFAULT_MODEL } from "@/client/constants/llm";
|
||||
|
||||
const PROMPT = `You are an AI writing assistant specialized in writing copy for resumes.
|
||||
Do not return anything else except the text you improved. It should not begin with a newline. It should not have any prefix or suffix text.
|
||||
@ -17,10 +19,12 @@ type Mood = "casual" | "professional" | "confident" | "friendly";
|
||||
export const changeTone = async (text: string, mood: Mood) => {
|
||||
const prompt = PROMPT.replace("{mood}", mood).replace("{input}", text);
|
||||
|
||||
const { model, maxTokens } = useOpenAiStore.getState();
|
||||
|
||||
const result = await openai().chat.completions.create({
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
model: "gpt-3.5-turbo",
|
||||
max_tokens: 1024,
|
||||
model: model ?? DEFAULT_MODEL,
|
||||
max_tokens: maxTokens ?? DEFAULT_MAX_TOKENS,
|
||||
temperature: 0.5,
|
||||
stop: ['"""'],
|
||||
n: 1,
|
||||
|
||||
@ -4,7 +4,7 @@ import { OpenAI } from "openai";
|
||||
import { useOpenAiStore } from "@/client/stores/openai";
|
||||
|
||||
export const openai = () => {
|
||||
const { apiKey } = useOpenAiStore.getState();
|
||||
const { apiKey, baseURL } = useOpenAiStore.getState();
|
||||
|
||||
if (!apiKey) {
|
||||
throw new Error(
|
||||
@ -12,6 +12,14 @@ export const openai = () => {
|
||||
);
|
||||
}
|
||||
|
||||
if(baseURL) {
|
||||
return new OpenAI({
|
||||
baseURL,
|
||||
apiKey,
|
||||
dangerouslyAllowBrowser: true,
|
||||
});
|
||||
}
|
||||
|
||||
return new OpenAI({
|
||||
apiKey,
|
||||
dangerouslyAllowBrowser: true,
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
import { openai } from "./client";
|
||||
import { useOpenAiStore } from "@/client/stores/openai";
|
||||
import { DEFAULT_MAX_TOKENS, DEFAULT_MODEL } from "@/client/constants/llm";
|
||||
|
||||
const PROMPT = `You are an AI writing assistant specialized in writing copy for resumes.
|
||||
Do not return anything else except the text you improved. It should not begin with a newline. It should not have any prefix or suffix text.
|
||||
@ -15,10 +17,12 @@ Revised Text: """`;
|
||||
export const fixGrammar = async (text: string) => {
|
||||
const prompt = PROMPT.replace("{input}", text);
|
||||
|
||||
const { model, maxTokens } = useOpenAiStore.getState();
|
||||
|
||||
const result = await openai().chat.completions.create({
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
model: "gpt-3.5-turbo",
|
||||
max_tokens: 1024,
|
||||
model: model ?? DEFAULT_MODEL,
|
||||
max_tokens: maxTokens ?? DEFAULT_MAX_TOKENS,
|
||||
temperature: 0,
|
||||
stop: ['"""'],
|
||||
n: 1,
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
import { openai } from "./client";
|
||||
import { useOpenAiStore } from "@/client/stores/openai";
|
||||
import { DEFAULT_MAX_TOKENS, DEFAULT_MODEL } from "@/client/constants/llm";
|
||||
|
||||
const PROMPT = `You are an AI writing assistant specialized in writing copy for resumes.
|
||||
Do not return anything else except the text you improved. It should not begin with a newline. It should not have any prefix or suffix text.
|
||||
@ -15,10 +17,12 @@ Revised Text: """`;
|
||||
export const improveWriting = async (text: string) => {
|
||||
const prompt = PROMPT.replace("{input}", text);
|
||||
|
||||
const { model, maxTokens } = useOpenAiStore.getState();
|
||||
|
||||
const result = await openai().chat.completions.create({
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
model: "gpt-3.5-turbo",
|
||||
max_tokens: 1024,
|
||||
model: model ?? DEFAULT_MODEL,
|
||||
max_tokens: maxTokens ?? DEFAULT_MAX_TOKENS,
|
||||
temperature: 0,
|
||||
stop: ['"""'],
|
||||
n: 1,
|
||||
|
||||
Reference in New Issue
Block a user