-
Notifications
You must be signed in to change notification settings - Fork 14
Wanda carlson patch 1113 #2412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Wanda carlson patch 1113 #2412
Changes from all commits
763c4f8
3aaeb87
ebd779c
f3ba89c
c7c9d0a
bd2235d
1a96b06
cf725d5
ebbc10b
bb3098c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,10 @@ | ||
| print("Henry testing v0.8.0") | ||
| print("Henry testing v0.8.0") | ||
| print("Henry testing v0.8.0") | ||
| print("Henry testing v0.8.0") | ||
| print("Henry testing v0.8.0") | ||
|
|
||
| creating a new draft PR | ||
| yet another draft PR | ||
| and another draft PR | ||
| and yet another draft PR | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| require('dotenv').config() | ||
| const express = require('express') | ||
| const cors = require('cors') | ||
| const path = require('path') | ||
| const providers = require('./src/llm/providers') | ||
|
|
||
| const app = express() | ||
| const port = process.env.PORT || 3000 | ||
|
|
||
| // Middleware | ||
| app.use(cors()) | ||
| app.use(express.json()) | ||
| app.use(express.static('public')) | ||
|
|
||
| // Get available providers and models | ||
| app.get('/api/providers', (req, res) => { | ||
| const providerInfo = Object.entries(providers).map(([id, provider]) => ({ | ||
| id, | ||
| name: provider.name, | ||
| models: provider.models | ||
| })) | ||
| res.json(providerInfo) | ||
| }) | ||
|
|
||
| // Generate article endpoint | ||
| app.post('/api/generate-article', async (req, res) => { | ||
| try { | ||
| const { topic, provider: providerId, model } = req.body | ||
|
|
||
| if (!topic) { | ||
| return res.status(400).json({ error: 'Topic is required' }) | ||
| } | ||
|
|
||
| if (!providerId || !providers[providerId]) { | ||
| return res.status(400).json({ error: 'Invalid provider' }) | ||
| } | ||
|
|
||
| if (!model || !providers[providerId].models.includes(model)) { | ||
| return res.status(400).json({ error: 'Invalid model for provider' }) | ||
| } | ||
|
|
||
| const provider = providers[providerId] | ||
| const prompt = `Write a short, informative article about ${topic}. The article should be between 200-300 words.` | ||
|
|
||
| try { | ||
| const article = await provider.generate(provider.client, model, prompt) | ||
| res.json({ article, provider: provider.name, model }) | ||
| } catch (error) { | ||
| console.error(`Error with ${provider.name}:`, error) | ||
| res.status(500).json({ error: `Failed to generate article using ${provider.name}` }) | ||
| } | ||
| } catch (error) { | ||
| console.error('Error:', error) | ||
| res.status(500).json({ error: 'Failed to process request' }) | ||
| } | ||
| }) | ||
|
|
||
| app.listen(port, () => { | ||
| console.log(`Server running on port ${port}`) | ||
| }) | ||
|
Comment on lines
+1
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Wrong language/file type: Node/Express code checked into a .py file. This won’t run and will trip Python linters/CI. Also, it appears to start another Express server on port 3000, duplicating wanda/server.js and risking port conflicts. Apply these steps:
Delete mistaken Python file: - require('dotenv').config()
- const express = require('express')
- const cors = require('cors')
- const path = require('path')
- const providers = require('./src/llm/providers')
- ...
- app.listen(port, () => {
- console.log(`Server running on port ${port}`)
- })
+ # (file removed; moved to JS)New server file (outside current range) for clarity: // src/llm/server.js
require('dotenv').config()
const express = require('express')
const cors = require('cors')
const providers = require('./providers') // e.g., src/llm/providers/index.js
const app = express()
const port = process.env.PORT || 3001 // avoid 3000 clash with wanda/server.js
app.use(cors())
app.use(express.json())
app.get('/api/providers', (req, res) => {
const info = Object.entries(providers).map(([id, p]) => ({ id, name: p.name, models: p.models }))
res.json(info)
})
app.post('/api/generate-article', async (req, res) => {
const { topic, provider: providerId, model } = req.body
if (typeof topic !== 'string' || topic.trim().length === 0 || topic.length > 512) {
return res.status(400).json({ error: 'Topic is required' })
}
const p = providers[providerId]
if (!p) return res.status(400).json({ error: 'Invalid provider' })
if (!model || !p.models.includes(model)) return res.status(400).json({ error: 'Invalid model for provider' })
try {
const prompt = `Write a short, informative article about ${topic}. The article should be between 200-300 words.`
const article = await p.generate(p.client, model, prompt)
res.json({ article, provider: p.name, model })
} catch (err) {
console.error(`Error with ${p.name}:`, err)
res.status(500).json({ error: `Failed to generate article using ${p.name}` })
}
})
app.listen(port, () => console.log(`Server running on port ${port}`))Unify both servers behind one Express app if possible to simplify deployment and routing. 🧰 Tools🪛 Ruff (0.12.2)2-2: SyntaxError: Simple statements must be separated by newlines or semicolons 3-3: SyntaxError: Simple statements must be separated by newlines or semicolons 4-4: SyntaxError: Simple statements must be separated by newlines or semicolons 5-5: SyntaxError: Simple statements must be separated by newlines or semicolons 7-7: SyntaxError: Simple statements must be separated by newlines or semicolons 8-8: SyntaxError: Simple statements must be separated by newlines or semicolons 8-8: SyntaxError: Expected an expression 10-10: SyntaxError: Expected a statement 15-15: SyntaxError: Expected a statement 15-15: SyntaxError: Simple statements must be separated by newlines or semicolons 15-15: SyntaxError: Simple statements must be separated by newlines or semicolons 16-16: SyntaxError: Expected a parameter name 16-16: SyntaxError: Expected an expression 17-17: SyntaxError: Expected ',', found name 17-17: SyntaxError: Expected ',', found '=' 17-17: SyntaxError: Expected a parameter name 17-17: SyntaxError: Expected an expression 19-19: SyntaxError: Expected ',', found ':' 20-20: SyntaxError: Expected ',', found ':' 22-22: SyntaxError: Expected ',', found name 25-25: SyntaxError: Expected a statement 25-25: SyntaxError: Simple statements must be separated by newlines or semicolons 25-25: SyntaxError: Simple statements must be separated by newlines or semicolons 26-26: SyntaxError: Expected ')', found 'async' 26-26: SyntaxError: Expected 'def', 'with' or 'for' to follow 'async', found '(' 26-26: SyntaxError: Expected an expression 27-27: SyntaxError: Expected an identifier, but found a keyword 'try' that cannot be used here 27-27: SyntaxError: Expected ',', found '{' 28-28: SyntaxError: Expected ',', found '{' 28-28: SyntaxError: Expected ',', found ':' 28-28: SyntaxError: Expected ',', found '=' 30-30: SyntaxError: Expected an expression 30-30: SyntaxError: Expected ',', found ')' 31-31: SyntaxError: Expected an identifier, but found a keyword 'return' that cannot be used here 31-31: SyntaxError: Expected ',', found name 34-34: SyntaxError: Expected an expression 34-34: SyntaxError: Expected an expression 34-34: SyntaxError: Expected an expression 34-34: SyntaxError: Expected ',', found ')' 35-35: SyntaxError: Expected an identifier, but found a keyword 'return' that cannot be used here 35-35: SyntaxError: Expected ',', found name 38-38: SyntaxError: Expected an expression 38-38: SyntaxError: Expected an expression 38-38: SyntaxError: Expected an expression 38-38: SyntaxError: Expected ',', found ')' 39-39: SyntaxError: Expected an identifier, but found a keyword 'return' that cannot be used here 39-39: SyntaxError: Expected ',', found name 42-42: SyntaxError: Expected ',', found name 42-42: SyntaxError: Expected ',', found name 42-42: SyntaxError: Expected ',', found '=' 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found '=' 43-43: SyntaxError: Got unexpected token ` 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Got unexpected token $ 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Expected ',', found int 43-43: SyntaxError: Expected ',', found name 43-43: SyntaxError: Got unexpected token ` 43-44: SyntaxError: Expected '}', found NonLogicalNewline 45-45: SyntaxError: Unexpected indentation 45-45: SyntaxError: Expected ':', found '{' 46-46: SyntaxError: Expected ',', found name 46-46: SyntaxError: Expected ',', found '=' 47-47: SyntaxError: Expected ',', found name 47-47: SyntaxError: Expected ',', found ':' 48-48: SyntaxError: Simple statements must be separated by newlines or semicolons 48-48: SyntaxError: Simple statements must be separated by newlines or semicolons 49-49: SyntaxError: Got unexpected token ` 49-49: SyntaxError: Expected ')', found 'with' 49-49: SyntaxError: Got unexpected token $ 49-49: SyntaxError: Invalid annotated assignment target 49-49: SyntaxError: Got unexpected token ` 49-49: SyntaxError: Expected a statement 49-49: SyntaxError: Expected a statement 49-50: SyntaxError: Expected a statement 50-50: SyntaxError: Unexpected indentation 50-50: SyntaxError: Got unexpected token ` 50-50: SyntaxError: Expected ':', found name 50-50: SyntaxError: Expected ',', found name 50-50: SyntaxError: Expected ':', found name 50-50: SyntaxError: Expected ',', found name 50-50: SyntaxError: Got unexpected token $ 50-50: SyntaxError: Got unexpected token ` 51-51: SyntaxError: Expected a statement 51-52: SyntaxError: Expected a statement 52-52: SyntaxError: unindent does not match any outer indentation level 52-52: SyntaxError: Expected a statement 52-52: SyntaxError: Simple statements must be separated by newlines or semicolons 54-54: SyntaxError: Expected ',', found name 56-56: SyntaxError: Expected a statement 56-56: SyntaxError: Expected a statement 56-57: SyntaxError: Expected a statement 58-58: SyntaxError: Expected a parameter name 58-58: SyntaxError: Expected an expression 59-59: SyntaxError: Got unexpected token ` 59-59: SyntaxError: Expected ',', found name 59-59: SyntaxError: Expected ',', found name 59-59: SyntaxError: Expected ',', found name 59-59: SyntaxError: Got unexpected token $ 59-59: SyntaxError: Got unexpected token ` 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| require('dotenv').config() | ||||||||||||||||||||||||||||||||||||||||||||||
| const express = require('express') | ||||||||||||||||||||||||||||||||||||||||||||||
| const cors = require('cors') | ||||||||||||||||||||||||||||||||||||||||||||||
| const OpenAI = require('openai') | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const app = express() | ||||||||||||||||||||||||||||||||||||||||||||||
| const port = process.env.PORT || 3000 | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Initialize OpenAI client | ||||||||||||||||||||||||||||||||||||||||||||||
| const openai = new OpenAI({ | ||||||||||||||||||||||||||||||||||||||||||||||
| apiKey: process.env.OPENAI_API_KEY | ||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add client reliability controls and early API key validation. Configure OpenAI SDK timeouts/retries and fail fast if OPENAI_API_KEY is missing. The SDK supports maxRetries and timeout on the client. (github.com) -const openai = new OpenAI({
- apiKey: process.env.OPENAI_API_KEY
-})
+if (!process.env.OPENAI_API_KEY) {
+ throw new Error('OPENAI_API_KEY is not set')
+}
+const openai = new OpenAI({
+ apiKey: process.env.OPENAI_API_KEY,
+ timeout: 20_000, // 20s
+ maxRetries: 2 // SDK default is 2; set explicitly
+})📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Middleware | ||||||||||||||||||||||||||||||||||||||||||||||
| app.use(cors()) | ||||||||||||||||||||||||||||||||||||||||||||||
| app.use(express.json()) | ||||||||||||||||||||||||||||||||||||||||||||||
| app.use(express.static('public')) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Generate article endpoint | ||||||||||||||||||||||||||||||||||||||||||||||
| app.post('/api/generate-article', async (req, res) => { | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| const { topic } = req.body | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (!topic) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return res.status(400).json({ error: 'Topic is required' }) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Harden input validation. Validate string type, trim, and length to avoid abuse and excessive prompt sizes. - if (!topic) {
+ if (typeof topic !== 'string' || topic.trim().length === 0 || topic.length > 512) {
return res.status(400).json({ error: 'Topic is required' })
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const completion = await openai.chat.completions.create({ | ||||||||||||||||||||||||||||||||||||||||||||||
| model: "gpt-3.5-turbo", | ||||||||||||||||||||||||||||||||||||||||||||||
| messages: [ | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| role: "system", | ||||||||||||||||||||||||||||||||||||||||||||||
| content: "You are a helpful assistant that generates short, informative articles." | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| role: "user", | ||||||||||||||||||||||||||||||||||||||||||||||
| content: `Write a short, informative article about ${topic}. The article should be between 200-300 words.` | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. security: 🤖 AI Agent Prompt for Cursor/Windsurf
📝 Committable Code Suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||
| temperature: 0.7, | ||||||||||||||||||||||||||||||||||||||||||||||
| max_tokens: 500 | ||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const article = completion.choices[0].message.content | ||||||||||||||||||||||||||||||||||||||||||||||
| res.json({ article }) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correctness: 🤖 AI Agent Prompt for Cursor/Windsurf
📝 Committable Code Suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.error('Error:', error) | ||||||||||||||||||||||||||||||||||||||||||||||
| res.status(500).json({ error: 'Failed to generate article' }) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| app.listen(port, () => { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`Server running on port ${port}`) | ||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SyntaxError: stray text lines — convert to code or comments.
Lines are not valid Python and will fail at import/execute.
Apply this minimal fix:
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.12.2)
7-7: SyntaxError: Simple statements must be separated by newlines or semicolons
7-7: SyntaxError: Simple statements must be separated by newlines or semicolons
7-7: SyntaxError: Simple statements must be separated by newlines or semicolons
7-7: SyntaxError: Simple statements must be separated by newlines or semicolons
8-8: SyntaxError: Simple statements must be separated by newlines or semicolons
8-8: SyntaxError: Simple statements must be separated by newlines or semicolons
8-8: SyntaxError: Simple statements must be separated by newlines or semicolons
9-9: SyntaxError: Expected a statement
9-9: SyntaxError: Simple statements must be separated by newlines or semicolons
9-9: SyntaxError: Simple statements must be separated by newlines or semicolons
10-10: SyntaxError: Expected a statement
10-10: SyntaxError: Simple statements must be separated by newlines or semicolons
10-10: SyntaxError: Simple statements must be separated by newlines or semicolons
10-10: SyntaxError: Simple statements must be separated by newlines or semicolons
🤖 Prompt for AI Agents