XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Add mode, cors

255706e7
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

4 个文件 +65 -2
Modified docker-compose.yml +1 -2
@@ -10,8 +10,7 @@ services:
10 10 volumes:
11 11 - .:/app
12 12 ports:
13 - '8080:8080'
14 - '1337:8080'
13 - '8090:8080'
15 14 - '7900:7900'
16 15 environment:
17 16 - OLLAMA_HOST=host.docker.internal
Added g4f.dev +1 -0
@@ -0,0 +1 @@
1 Subproject commit a4a9da6333d5fb69982230edf28fd27f8cb16933
Added main.js +8 -0
@@ -0,0 +1,8 @@
1 import Client from '@gpt4free/g4f.dev';
2
3 const client = new Client();
4 const result = await client.chat.completions.create({
5 model: 'gpt-4.1', // Or "gpt-4o", "deepseek-v3"
6 messages: [{ role: 'user', content: 'Explain quantum computing' }]
7 });
8 process.stdout.write(result.choices[0].message.content);
Added test.py +55 -0
@@ -0,0 +1,55 @@
1 import asyncio
2 from pathlib import Path
3
4 import g4f.debug
5 g4f.debug.logging = True
6
7 from g4f.Provider import PollinationsAI, Together, OpenaiAccount, CopilotAccount, BlackForestLabs_Flux1KontextDev
8 from g4f.client import AsyncClient
9
10 client = AsyncClient(provider=PollinationsAI)
11
12 # Example usage of the client to create image variations with different providers
13
14 ## This examples needs a absolute URL to the source image:
15
16 async def main():
17 result = await client.images.create_variation(
18 image="https://g4f.dev/docs/images/strawberry.jpg",
19 prompt="Remove background",
20 model="gpt-image",
21 response_format="url",
22 transparent=True)
23 print(result)
24
25 async def main_with_together():
26 result = await client.images.create_variation(
27 image="https://g4f.dev/docs/images/strawberry.jpg",
28 model="flux-kontext-pro",
29 provider=Together,
30 prompt="Add nature background",
31 response_format="url"
32 )
33 print(result)
34
35
36 async def main_with_copilot():
37 result = await client.images.create_variation(
38 image=Path("g4f.dev/docs/images/strawberry.jpg"),
39 provider=CopilotAccount,
40 prompt="Generate a variant of this image",
41 response_format="url"
42 )
43 print(result)
44
45
46 async def main_with_copilot():
47 result = await client.images.create_variation(
48 image=Path("g4f.dev/docs/images/strawberry.jpg"),
49 provider=BlackForestLabs_Flux1KontextDev,
50 prompt="Generate a variant of this image",
51 response_format="url"
52 )
53 print(result)
54
55 asyncio.run(main_with_copilot())