Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/henry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
creating a new draft PR
yet another draft PR
and another draft PR
and yet another draft PR
Comment on lines 7 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: These lines appear to be comments without proper Python comment syntax (#). Could cause syntax errors if executed.

Suggested change
creating a new draft PR
yet another draft PR
and another draft PR
and yet another draft PR
# creating a new draft PR
# yet another draft PR
# and another draft PR
# and yet another draft PR

60 changes: 60 additions & 0 deletions src/llm/providers.py
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}`)
})
54 changes: 54 additions & 0 deletions wanda/server.js
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
})

// 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' })
}

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.`
}
],
temperature: 0.7,
max_tokens: 500
})

const article = completion.choices[0].message.content
res.json({ article })
} 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}`)
})