msg.ts 598 B

123456789101112131415161718192021222324
  1. import { defineStore } from 'pinia'
  2. import OpenAI from 'openai'
  3. export const useMsgStore = defineStore('msg', {
  4. state: () => ({
  5. msgUuid: <string>'',
  6. messages: <any[]>[],
  7. pageInfoList: [],
  8. AIModel: <any>{},
  9. openai: <any>null
  10. }),
  11. actions: {
  12. updateAIModel(model: any) {
  13. this.AIModel = model
  14. this.openai = new OpenAI({
  15. // apiKey: import.meta.env.VITE_OPENAI_API_KEY_TONG,
  16. apiKey: import.meta.env.VITE_OPENAI_API_KEY_TONG,
  17. baseURL: this.AIModel.url,
  18. // timeout: 5000,
  19. dangerouslyAllowBrowser: true
  20. })
  21. }
  22. }
  23. })