File size: 1,807 Bytes
4782147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import path from "path";
import * as fs from "fs";

const CONFIG_TEMPLATE = `
import { type OpenAICompatibleProvider } from "./src/lib/ai/create-openai-compatiable";

const providers: OpenAICompatibleProvider[] = [
  // example
  // {
  //   provider: "Groq",
  //   apiKey: "123",
  //   baseUrl: "https://api.groq.com/openai/v1",
  //   models: [
  //     {
  //       apiName: "llama3-8b-8192",
  //       uiName: "Llama 3 8B",
  //       supportsTools: true,
  //     },
  //     {
  //       apiName: "mixtral-8x7b-32768",
  //       uiName: "Mixtral 8x7B",
  //       supportsTools: true,
  //     },
  //     {
  //       apiName: "gemma-7b-it",
  //       uiName: "Gemma 7B IT",
  //       supportsTools: false,
  //     },
  //   ],
  // },

  // Example configuration for Azure OpenAI
  // {
  //   provider: "Azure OpenAI",
  //   apiKey: "YOUR_AZURE_OPENAI_API_KEY",
  //   baseUrl: "https://your-azure-resource.openai.azure.com/openai/deployments/",
  //   models: [
  //     {
  //       apiName: "your-deployment-name",
  //       uiName: "GPT-4o (Azure Example)",
  //       supportsTools: true,
  //       apiVersion: "2025-01-01-preview",
  //     },
  //   ],
  // },
];

export default providers;

`.trim();

const ROOT = process.cwd();
const FILE_NAME = "openai-compatible.config.ts";
const CONFIG_PATH = path.join(ROOT, FILE_NAME);

function createConfigFile() {
  if (!fs.existsSync(CONFIG_PATH)) {
    try {
      fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE, "utf-8");
      console.log(`${FILE_NAME} file has been created.`);
    } catch (error) {
      console.error(`Error occurred while creating ${FILE_NAME} file.`);
      console.error(error);
      return false;
    }
  } else {
    console.info(`${FILE_NAME} file already exists. Skipping...`);
  }
}

createConfigFile();