codacus commited on
Commit
dc20bbc
·
unverified ·
1 Parent(s): 5d1816b

feat: added anthropic dynamic models (#1374)

Browse files
.cursorrules DELETED
@@ -1,157 +0,0 @@
1
- # Project Overview
2
-
3
- bolt.diy (previously oTToDev) is an open-source AI-powered full-stack web development platform that allows users to choose different LLM providers for coding assistance. The project supports multiple AI providers including OpenAI, Anthropic, Ollama, OpenRouter, Gemini, LMStudio, Mistral, xAI, HuggingFace, DeepSeek, and Groq.
4
-
5
- # Personality
6
-
7
- - Professional and technically precise
8
- - Focus on best practices and clean code
9
- - Provide clear explanations for code changes
10
- - Maintain consistent code style with the existing codebase
11
-
12
- # Techstack
13
-
14
- - Framework: Remix
15
- - Runtime: Node.js (>=18.18.0)
16
- - Package Manager: pnpm
17
- - UI: React with TypeScript
18
- - Styling: UnoCSS
19
- - Development Environment: Vite
20
- - Testing: Vitest
21
- - Deployment: Cloudflare Pages
22
- - Containerization: Docker
23
- - Code Quality: ESLint, Prettier, TypeScript
24
-
25
- # our .env file
26
-
27
- - Follow .env.example for required environment variables
28
- - Keep API keys and sensitive data in .env.local
29
- - Never commit .env files (they are gitignored)
30
-
31
- # Error Fixing Process
32
-
33
- 1. Identify the root cause through error messages and logs
34
- 2. Check relevant components and dependencies
35
- 3. Verify type safety and TypeScript compliance
36
- 4. Test changes locally before committing
37
- 5. Follow existing error handling patterns
38
-
39
- # Our Codebase
40
-
41
- - Main application code in /app directory
42
- - Components follow a modular structure
43
- - Server-side code in app/lib/.server
44
- - Client-side utilities in app/lib/
45
- - Type definitions in types/ directory
46
- - Documentation in docs/ directory
47
-
48
- # Current File Structure
49
-
50
- - /app - Main application code
51
- - /docs - Documentation
52
- - /functions - Serverless functions
53
- - /public - Static assets
54
- - /scripts - Build and utility scripts
55
- - /types - TypeScript definitions
56
- - /icons - SVG icons and assets
57
-
58
- # github upload process
59
-
60
- 1. Follow conventional commit messages
61
- 2. Run linting and tests before committing
62
- 3. Create feature branches for new work
63
- 4. Submit PRs with clear descriptions
64
- 5. Ensure CI/CD checks pass
65
-
66
- # Important
67
-
68
- - Keep dependencies updated
69
- - Follow TypeScript strict mode
70
- - Maintain backward compatibility
71
- - Document API changes
72
- - Test cross-browser compatibility
73
-
74
- # comments
75
-
76
- - Use JSDoc for function documentation
77
- - Keep comments clear and concise
78
- - Document complex logic and business rules
79
- - Update comments when changing code
80
- - Remove redundant comments
81
- - Always write comments that are relevant to the code they describe
82
- - Ensure comments explain the "why" not just the "what"
83
-
84
- # code review
85
-
86
- - Check for type safety
87
- - Verify error handling
88
- - Ensure code follows project patterns
89
- - Look for performance implications
90
- - Validate accessibility standards
91
-
92
- # code writing
93
-
94
- - Follow TypeScript best practices
95
- - Use functional components for React
96
- - Implement proper error boundaries
97
- - Write testable code
98
- - Follow the DRY principle
99
-
100
- # code refactoring
101
-
102
- - Maintain backward compatibility
103
- - Update tests alongside changes
104
- - Document breaking changes
105
- - Follow the project's type system
106
- - Keep components modular and reusable
107
-
108
- # Development Process
109
-
110
- - Write 3 reasoning paragraphs before implementing solutions
111
- - Analyze the problem space thoroughly before jumping to conclusions
112
- - Consider all edge cases and potential impacts
113
- - Process tasks with a Senior Developer mindset
114
- - Continue working until the solution is complete and verified
115
- - Remember and consider the full commit/change history when working
116
-
117
- # Code Quality Guidelines
118
-
119
- - Fewer lines of code is better, but not at the expense of readability
120
- - Preserve existing comments and documentation
121
- - Add meaningful comments explaining complex logic or business rules
122
- - Follow the principle of "Clean Code, Clear Intent"
123
- - Balance between conciseness and maintainability
124
- - Think twice, code once - avoid premature optimization
125
- - Never add comments just for the sake of commenting - ensure they add value
126
-
127
- # Problem Solving Approach
128
-
129
- 1. Understand the context fully before making changes
130
- 2. Document your reasoning and assumptions
131
- 3. Consider alternative approaches and their trade-offs
132
- 4. Validate your solution against existing patterns
133
- 5. Test thoroughly before considering work complete
134
- 6. Review impact on related components
135
-
136
- # UI GUIDELINES
137
-
138
- - Use consistent colors and typography
139
- - Ensure UI is responsive and accessible
140
- - Provide clear feedback for user actions
141
- - Use meaningful icons and labels
142
- - Keep UI clean and organized
143
- - Use consistent spacing and alignment
144
- - Use consistent naming conventions for components and variables
145
- - Use consistent file and folder structure
146
- - Use consistent naming conventions for components and variables
147
- - Use consistent file and folder structure
148
-
149
- # Style Guide
150
-
151
- - Use consistent naming conventions for components and variables
152
- - Use consistent file and folder structure
153
- - Respect the Light/Dark mode
154
- - Don't use white background for dark mode
155
- - Don't use white text on white background for dark mode
156
- - Match the style of the existing codebase
157
- - Use consistent naming conventions for components and variables
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore CHANGED
@@ -43,5 +43,4 @@ app/commit.json
43
  changelogUI.md
44
  docs/instructions/Roadmap.md
45
  .cursorrules
46
- .cursorrules
47
  *.md
 
43
  changelogUI.md
44
  docs/instructions/Roadmap.md
45
  .cursorrules
 
46
  *.md
app/lib/modules/llm/providers/anthropic.ts CHANGED
@@ -35,6 +35,44 @@ export default class AnthropicProvider extends BaseProvider {
35
  { name: 'claude-3-sonnet-20240229', label: 'Claude 3 Sonnet', provider: 'Anthropic', maxTokenAllowed: 8000 },
36
  { name: 'claude-3-haiku-20240307', label: 'Claude 3 Haiku', provider: 'Anthropic', maxTokenAllowed: 8000 },
37
  ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  getModelInstance: (options: {
39
  model: string;
40
  serverEnv: Env;
 
35
  { name: 'claude-3-sonnet-20240229', label: 'Claude 3 Sonnet', provider: 'Anthropic', maxTokenAllowed: 8000 },
36
  { name: 'claude-3-haiku-20240307', label: 'Claude 3 Haiku', provider: 'Anthropic', maxTokenAllowed: 8000 },
37
  ];
38
+
39
+ async getDynamicModels(
40
+ apiKeys?: Record<string, string>,
41
+ settings?: IProviderSetting,
42
+ serverEnv?: Record<string, string>,
43
+ ): Promise<ModelInfo[]> {
44
+ const { apiKey } = this.getProviderBaseUrlAndKey({
45
+ apiKeys,
46
+ providerSettings: settings,
47
+ serverEnv: serverEnv as any,
48
+ defaultBaseUrlKey: '',
49
+ defaultApiTokenKey: 'OPENAI_API_KEY',
50
+ });
51
+
52
+ if (!apiKey) {
53
+ throw `Missing Api Key configuration for ${this.name} provider`;
54
+ }
55
+
56
+ const response = await fetch(`https://api.anthropic.com/v1/models`, {
57
+ headers: {
58
+ 'x-api-key': `${apiKey}`,
59
+ 'anthropic-version': '2023-06-01',
60
+ },
61
+ });
62
+
63
+ const res = (await response.json()) as any;
64
+ const staticModelIds = this.staticModels.map((m) => m.name);
65
+
66
+ const data = res.data.filter((model: any) => model.type === 'model' && !staticModelIds.includes(model.id));
67
+
68
+ return data.map((m: any) => ({
69
+ name: m.id,
70
+ label: `${m.display_name}`,
71
+ provider: this.name,
72
+ maxTokenAllowed: 32000,
73
+ }));
74
+ }
75
+
76
  getModelInstance: (options: {
77
  model: string;
78
  serverEnv: Env;
app/lib/stores/settings.ts CHANGED
@@ -235,7 +235,7 @@ const getInitialTabConfiguration = (): TabWindowConfig => {
235
  }
236
  };
237
 
238
- console.log('Initial tab configuration:', getInitialTabConfiguration());
239
 
240
  export const tabConfigurationStore = map<TabWindowConfig>(getInitialTabConfiguration());
241
 
 
235
  }
236
  };
237
 
238
+ // console.log('Initial tab configuration:', getInitialTabConfiguration());
239
 
240
  export const tabConfigurationStore = map<TabWindowConfig>(getInitialTabConfiguration());
241