avglinuxguy
avglinuxguy
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
But the logs always showed some IP from India. Using the VPN worked.
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Nope, finally I found the issue was with the way CloudFlare handled the reqeust, since Google is geo-blocking in some countries, When I was using fiber internet it worked, but when I switched to mobile internet I don't know how cloudflare did it's routing, but it might have went to some geo-blocked country like EU etc.
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Need to find some other free LLM api
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
LOL What a pain.
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
It works with my HOME network but not with the mobile
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
ANS: it's not wokers it GEMINI API: giving this output. "Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent: [400 Bad Request] User location is not supported for the API use."
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
/v1 route is working but not the / route
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import { env, getRuntimeKey } from 'hono/adapter'
import { GoogleGenerativeAI } from '@google/generative-ai';

const app = new Hono();

app.use('/*', cors())

async function run(content: any) {
// For text-only input, use the gemini-pro model
const {GEMINI_API} = env(content)
const genAI = new GoogleGenerativeAI(GEMINI_API);
const model = genAI.getGenerativeModel({ model: "gemini-pro"});

const prompt = "Write a line."

const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();
return text
}

app.get('/', async (c) => {

const ans = await run(c);
return c.json({
message: 'Live!',
Quote: ans
})
})

app.get('/v1', async (c) => {

// const ans = await run(c);
return c.text("ans")
})


export default app;
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import { env, getRuntimeKey } from 'hono/adapter'
import { GoogleGenerativeAI } from '@google/generative-ai';

const app = new Hono();

app.use('/*', cors())

async function run(content: any) {
// For text-only input, use the gemini-pro model
const {GEMINI_API} = env(content)
const genAI = new GoogleGenerativeAI(GEMINI_API);
const model = genAI.getGenerativeModel({ model: "gemini-pro"});

const prompt = "Write a line."

const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();
return text
}

app.get('/', async (c) => {

const ans = await run(c);
return c.json({
message: 'Live!',
Quote: ans
})
})

app.get('/v1', async (c) => {

// const ans = await run(c);
return c.text("ans")
})


export default app;
I have this code, and I can't access it outside my home network. I don't know why
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
I didn't had cors in it, so was working with my IP only. Couldn't open the site from anyohter place
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
No description
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Let's see how can I do that
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
I will enable streaming now, so it gives words one by one.
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Just a little slow
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Yes, it working fine now.
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
No description
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Now, After the second deployment the errors vanished now no more errors.
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Just internal server error is there a console on on Cloudflare, let me check
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
import { Hono } from 'hono'
import { env, getRuntimeKey } from 'hono/adapter'
import { GoogleGenerativeAI } from '@google/generative-ai';

const app = new Hono();

async function run(content: any) {
// For text-only input, use the gemini-pro model
const {GEMINI_API} = env(content)
const genAI = new GoogleGenerativeAI(GEMINI_API);
const model = genAI.getGenerativeModel({ model: "gemini-pro"});

const prompt = "Write a story about a magic backpack."

const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();
return text
}

app.get('/', async (c) => {

// const {GEMINI_API} = env(c)
const ans = await run(c);
console.log(ans)
console.log("my key:")
return c.json({
message: 'Live!',
Quote: ans
})
})


export default app;
import { Hono } from 'hono'
import { env, getRuntimeKey } from 'hono/adapter'
import { GoogleGenerativeAI } from '@google/generative-ai';

const app = new Hono();

async function run(content: any) {
// For text-only input, use the gemini-pro model
const {GEMINI_API} = env(content)
const genAI = new GoogleGenerativeAI(GEMINI_API);
const model = genAI.getGenerativeModel({ model: "gemini-pro"});

const prompt = "Write a story about a magic backpack."

const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();
return text
}

app.get('/', async (c) => {

// const {GEMINI_API} = env(c)
const ans = await run(c);
console.log(ans)
console.log("my key:")
return c.json({
message: 'Live!',
Quote: ans
})
})


export default app;
Am I doing it right, it's working, but sometimes give internal server error.
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Like I need the value of env in my run()
37 replies
CDCloudflare Developers
Created by avglinuxguy on 3/11/2024 in #general-help
How to access env variables?
Ok, so I can do this right? let output = await run(c); ??
37 replies