screenshot-to-code
screenshot-to-code copied to clipboard
Ollama Support
I love your project, I want to use it with local ollama+llava and i tried many way including asking chat gpt. I am on Windows 11, i tried docker and no go. changed api address from settings in frontend also
api key as "ollama" and
Api Url as http://localhost:11434/v1/
and i tested my local ollama+llava answering and running with postman.
changed frontend\src\lib\models.ts
// Keep in sync with backend (llm.py)
// Order here matches dropdown order
export enum CodeGenerationModel {
GPT_4O_2024_05_13 = "llava", --> HERE
GPT_4_TURBO_2024_04_09 = "gpt-4-turbo-2024-04-09",
GPT_4_VISION = "gpt_4_vision",
CLAUDE_3_SONNET = "claude_3_sonnet",
}
// Will generate a static error if a model in the enum above is not in the descriptions
export const CODE_GENERATION_MODEL_DESCRIPTIONS: {
[key in CodeGenerationModel]: { name: string; inBeta: boolean };
} = {
"llava": { name: "LLava", inBeta: false }, --> and here
"gpt-4-turbo-2024-04-09": { name: "GPT-4 Turbo (Apr 2024)", inBeta: false },
gpt_4_vision: { name: "GPT-4 Vision (Nov 2023)", inBeta: false },
claude_3_sonnet: { name: "Claude 3 Sonnet", inBeta: false },
};
also backend\llm.py
Actual model versions that are passed to the LLMs and stored in our logs
class Llm(Enum):
GPT_4_VISION = "gpt-4-vision-preview"
GPT_4_TURBO_2024_04_09 = "gpt-4-turbo-2024-04-09"
GPT_4O_2024_05_13 = "llava"
CLAUDE_3_SONNET = "claude-3-sonnet-20240229"
CLAUDE_3_OPUS = "claude-3-opus-20240229"
CLAUDE_3_HAIKU = "claude-3-haiku-20240307"
Will throw errors if you send a garbage string
def convert_frontend_str_to_llm(frontend_str: str) -> Llm:
if frontend_str == "gpt_4_vision":
return Llm.GPT_4_VISION
elif frontend_str == "claude_3_sonnet":
return Llm.CLAUDE_3_SONNET
elif frontend_str == "llava":
return Llm.GPT_4O_2024_05_13
else:
return Llm(frontend_str)
console and backend errors below
INFO: ('127.0.0.1', 57364) - "WebSocket /generate-code" [accepted]
Incoming websocket connection...
INFO: connection open
Received params
Generating html_tailwind code for uploaded image using Llm.GPT_4O_2024_05_13 model...
Using OpenAI API key from client-side settings dialog
Using OpenAI Base URL from client-side settings dialog
generating code...
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 250, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\fastapi\applications.py", line 276, in __call__
await super().__call__(scope, receive, send)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\starlette\applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\starlette\middleware\errors.py", line 149, in __call__
await self.app(scope, receive, send)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\starlette\middleware\cors.py", line 75, in __call__
await self.app(scope, receive, send)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
raise exc
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
raise e
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\starlette\routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\starlette\routing.py", line 341, in handle
await self.app(scope, receive, send)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\starlette\routing.py", line 82, in app
await func(session)
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\fastapi\routing.py", line 289, in app
await dependant.call(**values)
File "C:\Users\k\screenshot-to-code\backend\routes\generate_code.py", line 262, in stream_code
completion = await stream_openai_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\k\screenshot-to-code\backend\llm.py", line 60, in stream_openai_response
stream = await client.chat.completions.create(**params) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\k\AppData\Local\pypoetry\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\openai\resources\chat\completions.py", line 1334, in create
return await self._post(
^^^^^^^^^^^^^^^^^
y\Cache\virtualenvs\backend-bYKjg4sG-py3.11\Lib\site-packages\openai\_base_client.py", line 1532, in _request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': 'json: cannot unmarshal array into Go struct field Message.messages.content of type string', 'type': 'invalid_request_error', 'param': None, 'code': None}}
INFO: connection closed
If can be use on local server it'll be awesome! Thanks for consideration
We're definitely interested in adding Ollama support to this project. Thanks for opening this issue.
I'm also looking forward to this feature! ✨
👀
Yeah, it will would great to support ollama, LM studio, llama.cpp and more well-known opensource LLMs, like MiniCPM for vision.
how's it going now?
👀
Ollama already has a OpenAI-compatible API, so all you have to do is change the env variable and create model aliases.
Add to backend/.env
export OPENAI_BASE_URL="http://localhost:11434/v1"
export OPENAI_API_KEY=fake-key
Then create aliases for the models that screenshot-to-code-uses
for model in \
claude-3-5-sonnet-20240620 \
gpt-4o-2024-05-13 \
gpt-4-turbo-2024-04-09 \
gpt_4_vision \
claude_3_sonnet; do
ollama cp x/llama3.2-vision $model
done
Then it will call your local models when it makes LLM requests. Change x/llama3.2-vision to whatever model you want.
I've not gotten very good success because all I can run is a 13b model but perhaps the more powerful models will work well.
Note: you need 0.4.0 release of ollama to run the llama-vision model https://medium.com/@tapanbabbar/how-to-run-llama-3-2-vision-on-ollama-a-game-changer-for-edge-ai-80cb0e8d8928.
@pdufour thanks for the tip! I'll include this on the README.
export OPENAI_BASE_URL="http://localhost:11434/v1" export OPENAI_API_KEY=fake-key
Got this error:
openai.InternalServerError: Error code: 500 - {'error': {'message': 'llama runner process has terminated: error:Missing required key: clip.has_text_encoder', 'type': 'api_error', 'param': None, 'code': None}}
@immmor see https://github.com/ollama/ollama/issues/7300
ollama/ollama#7300
Thought my ollama is already 0.4.0... Still 0.3.14...
Thought my ollama is already 0.4.0... Still 0.3.14... You can download pre release https://github.com/ollama/ollama/releases/tag/v0.4.0-rc8
Just to clarify for the script kiddies out there. The "for model in" part is not able to be used in the windows command promt. I've only figured it out for powershell. So, open powershell.exe and paste this in:
$models = @( "claude-3-5-sonnet-20240620", "gpt-4o-2024-05-13", "gpt-4-turbo-2024-04-09", "gpt_4_vision", "claude_3_sonnet" ) foreach ($model in $models) { ollama cp x/llama3.2-vision $model }
How does ollama cp works if I'm running ollama in docker vs ollama installed on host? Right now, I have ollama docker setup on different PC on the same network.
For who using Powershell in windows can use script a file extension with .ps1 and run sa administrator to copy model name. but while u use this you need to change sourcemodel full name on ollama list command.
# Define the models in an array
$models = @(
"claude-3-5-sonnet-20240620",
"gpt-4o-2024-05-13",
"gpt-4-turbo-2024-04-09",
"gpt_4_vision",
"claude_3_sonnet"
)
# Define the source model
$sourceModel = "llama3.2-vision:11b-instruct-q8_0"
foreach ($model in $models) {
Write-Output "Copying $sourceModel to $model..."
& ollama cp $sourceModel $model
}
Ollama already has a OpenAI-compatible API, so all you have to do is change the env variable and create model aliases.
Add to
backend/.envexport OPENAI_BASE_URL="http://localhost:11434/v1" export OPENAI_API_KEY=fake-keyThen create aliases for the models that screenshot-to-code-uses
for model in \ claude-3-5-sonnet-20240620 \ gpt-4o-2024-05-13 \ gpt-4-turbo-2024-04-09 \ gpt_4_vision \ claude_3_sonnet; do ollama cp x/llama3.2-vision $model doneThen it will call your local models when it makes LLM requests. Change
x/llama3.2-visionto whatever model you want.I've not gotten very good success because all I can run is a 13b model but perhaps the more powerful models will work well.
Note: you need 0.4.0 release of ollama to run the llama-vision model https://medium.com/@tapanbabbar/how-to-run-llama-3-2-vision-on-ollama-a-game-changer-for-edge-ai-80cb0e8d8928.
but this will consume much disk space?
Ollama already has a OpenAI-compatible API, so all you have to do is change the env variable and create model aliases. Add to
backend/.envexport OPENAI_BASE_URL="http://localhost:11434/v1" export OPENAI_API_KEY=fake-keyThen create aliases for the models that screenshot-to-code-uses
for model in \ claude-3-5-sonnet-20240620 \ gpt-4o-2024-05-13 \ gpt-4-turbo-2024-04-09 \ gpt_4_vision \ claude_3_sonnet; do ollama cp x/llama3.2-vision $model doneThen it will call your local models when it makes LLM requests. Change
x/llama3.2-visionto whatever model you want. I've not gotten very good success because all I can run is a 13b model but perhaps the more powerful models will work well. Note: you need 0.4.0 release of ollama to run the llama-vision model https://medium.com/@tapanbabbar/how-to-run-llama-3-2-vision-on-ollama-a-game-changer-for-edge-ai-80cb0e8d8928.but this will consume much disk space?
ollama cp is just something like alias, so it doesn't consume much more disk space.
I tried above solutions, but it doesn't work for me.
Details
[root@ha-master-1 screenshot-to-code]# docker compose logs
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] /root/app/screenshot-to-code/compose.yml: `version` is obsolete
backend-1 | Skipping virtualenv creation, as specified in config file.
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/config_defaults.py:1: SyntaxWarning: invalid escape sequence '\P'
backend-1 | """
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:294: SyntaxWarning: invalid escape sequence '\d'
frontend-1 | yarn run v1.22.22
backend-1 | lines_video = [l for l in lines if ' Video: ' in l and re.search('\d+x\d+', l)]
frontend-1 | $ vite --host 0.0.0.0
frontend-1 |
frontend-1 | VITE v4.5.0 ready in 876 ms
frontend-1 |
frontend-1 | ➜ Local: http://localhost:5173/
frontend-1 | ➜ Network: http://192.168.80.2:5173/
frontend-1 |
frontend-1 | ERROR
frontend-1 | [TypeScript] Found 0 errors. Watching for file changes.
frontend-1 |
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:367: SyntaxWarning: invalid escape sequence '\d'
backend-1 | rotation_lines = [l for l in lines if 'rotate :' in l and re.search('\d+$', l)]
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:370: SyntaxWarning: invalid escape sequence '\d'
backend-1 | match = re.search('\d+$', rotation_line)
backend-1 | INFO: Started server process [1]
backend-1 | INFO: Waiting for application startup.
backend-1 | INFO: Application startup complete.
backend-1 | INFO: Uvicorn running on http://0.0.0.0:7001 (Press CTRL+C to quit)
[root@ha-master-1 screenshot-to-code]# docker compose logs -f
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] /root/app/screenshot-to-code/compose.yml: `version` is obsolete
frontend-1 | yarn run v1.22.22
frontend-1 | $ vite --host 0.0.0.0
frontend-1 |
frontend-1 | VITE v4.5.0 ready in 876 ms
frontend-1 |
frontend-1 | ➜ Local: http://localhost:5173/
frontend-1 | ➜ Network: http://192.168.80.2:5173/
frontend-1 |
frontend-1 | ERROR
frontend-1 | [TypeScript] Found 0 errors. Watching for file changes.
frontend-1 |
backend-1 | Skipping virtualenv creation, as specified in config file.
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/config_defaults.py:1: SyntaxWarning: invalid escape sequence '\P'
backend-1 | """
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:294: SyntaxWarning: invalid escape sequence '\d'
backend-1 | lines_video = [l for l in lines if ' Video: ' in l and re.search('\d+x\d+', l)]
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:367: SyntaxWarning: invalid escape sequence '\d'
backend-1 | rotation_lines = [l for l in lines if 'rotate :' in l and re.search('\d+$', l)]
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:370: SyntaxWarning: invalid escape sequence '\d'
backend-1 | match = re.search('\d+$', rotation_line)
backend-1 | INFO: Started server process [1]
backend-1 | INFO: Waiting for application startup.
backend-1 | INFO: Application startup complete.
backend-1 | INFO: Uvicorn running on http://0.0.0.0:7001 (Press CTRL+C to quit)
frontend-1 |
frontend-1 | WARN Browserslist: caniuse-lite is outdated. Please run:
frontend-1 | npx update-browserslist-db@latest
frontend-1 | Why you should do it regularly: https://github.com/browserslist/update-db#readme
frontend-1 |
^X^Z
[1]+ Stopped docker compose logs -f
[root@ha-master-1 screenshot-to-code]# vim compose.yml
[root@ha-master-1 screenshot-to-code]# docker compose up -d
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] /root/app/screenshot-to-code/compose.yml: `version` is obsolete
[+] Running 2/2
✔ Container screenshot-to-code-backend-1 Running 0.0s
✔ Container screenshot-to-code-frontend-1 Started 1.8s
[root@ha-master-1 screenshot-to-code]# vim compose.yml
[root@ha-master-1 screenshot-to-code]# docker compose up -d
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] /root/app/screenshot-to-code/compose.yml: `version` is obsolete
[+] Running 2/2
✔ Container screenshot-to-code-backend-1 Running 0.0s
✔ Container screenshot-to-code-frontend-1 Started 2.1s
[root@ha-master-1 screenshot-to-code]# docker compose logs
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] Found multiple config files with supported names: /root/app/screenshot-to-code/compose.yml, /root/app/screenshot-to-code/docker-compose.yml
WARN[0000] Using /root/app/screenshot-to-code/compose.yml
WARN[0000] /root/app/screenshot-to-code/compose.yml: `version` is obsolete
frontend-1 | yarn run v1.22.22
frontend-1 | $ vite --host 0.0.0.0
frontend-1 |
frontend-1 | VITE v4.5.0 ready in 874 ms
frontend-1 |
frontend-1 | ➜ Local: http://localhost:5173/
frontend-1 | ➜ Network: http://192.168.80.2:5173/
frontend-1 |
frontend-1 | ERROR
frontend-1 | [TypeScript] Found 0 errors. Watching for file changes.
frontend-1 |
frontend-1 |
frontend-1 | WARN Browserslist: caniuse-lite is outdated. Please run:
frontend-1 | npx update-browserslist-db@latest
frontend-1 | Why you should do it regularly: https://github.com/browserslist/update-db#readme
frontend-1 |
backend-1 | Skipping virtualenv creation, as specified in config file.
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/config_defaults.py:1: SyntaxWarning: invalid escape sequence '\P'
backend-1 | """
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:294: SyntaxWarning: invalid escape sequence '\d'
backend-1 | lines_video = [l for l in lines if ' Video: ' in l and re.search('\d+x\d+', l)]
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:367: SyntaxWarning: invalid escape sequence '\d'
backend-1 | rotation_lines = [l for l in lines if 'rotate :' in l and re.search('\d+$', l)]
backend-1 | /usr/local/lib/python3.12/site-packages/moviepy/video/io/ffmpeg_reader.py:370: SyntaxWarning: invalid escape sequence '\d'
backend-1 | match = re.search('\d+$', rotation_line)
backend-1 | INFO: Started server process [1]
backend-1 | INFO: Waiting for application startup.
backend-1 | INFO: Application startup complete.
backend-1 | INFO: Uvicorn running on http://0.0.0.0:7001 (Press CTRL+C to quit)
backend-1 | INFO: ('192.168.80.1', 40946) - "WebSocket /generate-code" [accepted]
backend-1 | INFO: connection open
backend-1 | Traceback (most recent call last):
backend-1 | File "/app/llm.py", line 76, in stream_openai_response
backend-1 | stream = await client.chat.completions.create(**params) # type: ignore
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions.py", line 1720, in create
backend-1 | return await self._post(
backend-1 | ^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1843, in post
backend-1 | return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1537, in request
backend-1 | return await self._request(
backend-1 | ^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1638, in _request
backend-1 | raise self._make_status_error_from_response(err.response) from None
backend-1 | openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4o-2024-11-20" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}
backend-1 | Traceback (most recent call last):
backend-1 | File "/app/llm.py", line 76, in stream_openai_response
backend-1 | stream = await client.chat.completions.create(**params) # type: ignore
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions.py", line 1720, in create
backend-1 | return await self._post(
backend-1 | ^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1843, in post
backend-1 | return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1537, in request
backend-1 | return await self._request(
backend-1 | ^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1638, in _request
backend-1 | raise self._make_status_error_from_response(err.response) from None
backend-1 | openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4o-2024-11-20" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}
backend-1 | ERROR: Exception in ASGI application
backend-1 | Traceback (most recent call last):
backend-1 | File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 250, in run_asgi
backend-1 | result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
backend-1 | return await self.app(scope, receive, send)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
backend-1 | await super().__call__(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
backend-1 | await self.middleware_stack(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 152, in __call__
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/cors.py", line 77, in __call__
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
backend-1 | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
backend-1 | raise exc
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
backend-1 | await app(scope, receive, sender)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
backend-1 | await self.middleware_stack(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
backend-1 | await route.handle(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 362, in handle
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 95, in app
backend-1 | await wrap_app_handling_exceptions(app, session)(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
backend-1 | raise exc
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
backend-1 | await app(scope, receive, sender)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 93, in app
backend-1 | await func(session)
backend-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 383, in app
backend-1 | await dependant.call(**solved_result.values)
backend-1 | File "/app/routes/generate_code.py", line 349, in stream_code
backend-1 | raise Exception("All generations failed")
backend-1 | Exception: All generations failed
backend-1 | INFO: connection closed
backend-1 | INFO: ('192.168.80.1', 54340) - "WebSocket /generate-code" [accepted]
backend-1 | INFO: connection open
backend-1 | Traceback (most recent call last):
backend-1 | File "/app/llm.py", line 76, in stream_openai_response
backend-1 | stream = await client.chat.completions.create(**params) # type: ignore
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions.py", line 1720, in create
backend-1 | return await self._post(
backend-1 | ^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1843, in post
backend-1 | return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1537, in request
backend-1 | return await self._request(
backend-1 | ^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1638, in _request
backend-1 | raise self._make_status_error_from_response(err.response) from None
backend-1 | openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4o-2024-11-20" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}
backend-1 | Traceback (most recent call last):
backend-1 | File "/app/llm.py", line 76, in stream_openai_response
backend-1 | stream = await client.chat.completions.create(**params) # type: ignore
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions.py", line 1720, in create
backend-1 | return await self._post(
backend-1 | ^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1843, in post
backend-1 | return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1537, in request
backend-1 | return await self._request(
backend-1 | ^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1638, in _request
backend-1 | raise self._make_status_error_from_response(err.response) from None
backend-1 | openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4o-2024-11-20" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}
backend-1 | ERROR: Exception in ASGI application
backend-1 | Traceback (most recent call last):
backend-1 | File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 250, in run_asgi
backend-1 | result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
backend-1 | return await self.app(scope, receive, send)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
backend-1 | await super().__call__(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
backend-1 | await self.middleware_stack(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 152, in __call__
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/cors.py", line 77, in __call__
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
backend-1 | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
backend-1 | raise exc
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
backend-1 | await app(scope, receive, sender)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
backend-1 | await self.middleware_stack(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
backend-1 | await route.handle(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 362, in handle
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 95, in app
backend-1 | await wrap_app_handling_exceptions(app, session)(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
backend-1 | raise exc
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
backend-1 | await app(scope, receive, sender)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 93, in app
backend-1 | await func(session)
backend-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 383, in app
backend-1 | await dependant.call(**solved_result.values)
backend-1 | File "/app/routes/generate_code.py", line 349, in stream_code
backend-1 | raise Exception("All generations failed")
backend-1 | Exception: All generations failed
backend-1 | INFO: connection closed
[root@ha-master-1 screenshot-to-code]# ollama --version
ollama version is 0.5.4
[root@ha-master-1 screenshot-to-code]# ollama ps
NAME ID SIZE PROCESSOR UNTIL
[root@ha-master-1 screenshot-to-code]# ollama list
NAME ID SIZE MODIFIED
claude-3-5-sonnet-20240620:latest 085a1fdae525 7.9 GB 36 minutes ago
gpt_4_vision:latest 085a1fdae525 7.9 GB 36 minutes ago
gpt-4o-2024-05-13:latest 085a1fdae525 7.9 GB 36 minutes ago
claude_3_sonnet:latest 085a1fdae525 7.9 GB 36 minutes ago
gpt-4-turbo-2024-04-09:latest 085a1fdae525 7.9 GB 36 minutes ago
llama3.2-vision:latest 085a1fdae525 7.9 GB 49 minutes ago
gemma:latest a72c7f4d0a15 5.0 GB 3 weeks ago
mistral:latest f974a74358d6 4.1 GB 3 weeks ago
qwen2.5:7b 845dbda0ea48 4.7 GB 3 weeks ago
qwen2.5:7b-instruct 845dbda0ea48 4.7 GB 3 weeks ago
llama3.2:latest a80c4f17acd5 2.0 GB 3 weeks ago
llama3:8b 365c0bd3c000 4.7 GB 3 weeks ago
phi3:latest 4f2222927938 2.2 GB 3 weeks ago
mixtral:latest d39eb76ed9c5 26 GB 6 weeks ago
nomic-embed-text:latest 0a109f422b47 274 MB 6 weeks ago
llava:latest 8dd30f6b0cb1 4.7 GB 6 weeks ago
shaw/dmeta-embedding-zh:latest 55960d8a3a42 408 MB 2 months ago
qwen2.5:1.5b 65ec06548149 986 MB 2 months ago
qwen2.5:0.5b a8b0c5157701 397 MB 2 months ago
codegemma:latest 0c96700aaada 5.0 GB 2 months ago
phi3.5:latest 61819fb370a3 2.2 GB 2 months ago
qwen2.5:latest 845dbda0ea48 4.7 GB 2 months ago
gemma2:latest ff02c3702f32 5.4 GB 2 months ago
[root@ha-master-1 screenshot-to-code]#
[root@ha-master-1 screenshot-to-code]# cat compose.yml
version: '3.9'
services:
backend:
image: liudonghua123/screenshot-to-code-backend
env_file:
- .env
ports:
- "3015:${BACKEND_PORT:-7001}"
environment:
- OPENAI_BASE_URL=http://host.docker.internal:11434/v1
extra_hosts:
- "host.docker.internal:host-gateway"
command: poetry run uvicorn main:app --host 0.0.0.0 --port ${BACKEND_PORT:-7001}
frontend:
image: liudonghua123/screenshot-to-code-frontend
ports:
- "5173:5173"
environment:
- VITE_WS_BACKEND_URL=ws://screenshot-to-code-backend.app.ynu.edu.cn
[root@ha-master-1 screenshot-to-code]#
I added OPENAI_LOG=debug to the environment of compose.yml to see more details. And I found openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4o-2024-11-20" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}.
I executed ollama cp gpt-4o-2024-05-13 gpt-4o-2024-11-20, now it worked.
So above gpt-4o-2024-05-13 need to updated to gpt-4o-2024-11-20.
See also https://github.com/All-Hands-AI/OpenHands/issues/1052.
https://github.com/abi/screenshot-to-code/blob/595d969fc369635eb1d468ab473cca87b390bf65/backend/routes/generate_code.py#L270-L274
Details
backend-1 | [2025-01-18 09:54:07 - httpx:1729 - INFO] HTTP Request: POST http://host.docker.internal:11434/v1/chat/completions "HTTP/1.1 404 Not Found"
backend-1 | [2025-01-18 09:54:07 - openai._base_client:1612 - DEBUG] HTTP Request: POST http://host.docker.internal:11434/v1/chat/completions "404 Not Found"
backend-1 | [2025-01-18 09:54:07 - openai._base_client:1619 - DEBUG] Encountered httpx.HTTPStatusError
backend-1 | Traceback (most recent call last):
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1617, in _request
backend-1 | response.raise_for_status()
backend-1 | File "/usr/local/lib/python3.12/site-packages/httpx/_models.py", line 758, in raise_for_status
backend-1 | raise HTTPStatusError(message, request=request, response=self)
backend-1 | httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://host.docker.internal:11434/v1/chat/completions'
backend-1 | For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
backend-1 | [2025-01-18 09:54:07 - openai._base_client:743 - DEBUG] Not retrying
backend-1 | [2025-01-18 09:54:07 - openai._base_client:1637 - DEBUG] Re-raising status error
backend-1 | [2025-01-18 09:54:07 - httpx:1729 - INFO] HTTP Request: POST http://host.docker.internal:11434/v1/chat/completions "HTTP/1.1 404 Not Found"
backend-1 | [2025-01-18 09:54:07 - openai._base_client:1612 - DEBUG] HTTP Request: POST http://host.docker.internal:11434/v1/chat/completions "404 Not Found"
backend-1 | [2025-01-18 09:54:07 - openai._base_client:1619 - DEBUG] Encountered httpx.HTTPStatusError
backend-1 | Traceback (most recent call last):
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1617, in _request
backend-1 | response.raise_for_status()
backend-1 | File "/usr/local/lib/python3.12/site-packages/httpx/_models.py", line 758, in raise_for_status
backend-1 | raise HTTPStatusError(message, request=request, response=self)
backend-1 | httpx.HTTPStatusError: Client error '404 Not Found' for url 'http://host.docker.internal:11434/v1/chat/completions'
backend-1 | For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
backend-1 | [2025-01-18 09:54:07 - openai._base_client:743 - DEBUG] Not retrying
backend-1 | [2025-01-18 09:54:07 - openai._base_client:1637 - DEBUG] Re-raising status error
backend-1 | Traceback (most recent call last):
backend-1 | File "/app/llm.py", line 76, in stream_openai_response
backend-1 | stream = await client.chat.completions.create(**params) # type: ignore
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions.py", line 1720, in create
backend-1 | return await self._post(
backend-1 | ^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1843, in post
backend-1 | return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1537, in request
backend-1 | return await self._request(
backend-1 | ^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1638, in _request
backend-1 | raise self._make_status_error_from_response(err.response) from None
backend-1 | openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4o-2024-11-20" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}
backend-1 | Traceback (most recent call last):
backend-1 | File "/app/llm.py", line 76, in stream_openai_response
backend-1 | stream = await client.chat.completions.create(**params) # type: ignore
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions.py", line 1720, in create
backend-1 | return await self._post(
backend-1 | ^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1843, in post
backend-1 | return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1537, in request
backend-1 | return await self._request(
backend-1 | ^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1638, in _request
backend-1 | raise self._make_status_error_from_response(err.response) from None
backend-1 | openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4o-2024-11-20" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}
backend-1 | ERROR: Exception in ASGI application
backend-1 | Traceback (most recent call last):
backend-1 | File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 250, in run_asgi
backend-1 | result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
backend-1 | return await self.app(scope, receive, send)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
backend-1 | await super().__call__(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
backend-1 | await self.middleware_stack(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 152, in __call__
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/cors.py", line 77, in __call__
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
backend-1 | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
backend-1 | raise exc
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
backend-1 | await app(scope, receive, sender)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
backend-1 | await self.middleware_stack(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
backend-1 | await route.handle(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 362, in handle
backend-1 | await self.app(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 95, in app
backend-1 | await wrap_app_handling_exceptions(app, session)(scope, receive, send)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
backend-1 | raise exc
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
backend-1 | await app(scope, receive, sender)
backend-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 93, in app
backend-1 | await func(session)
backend-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 383, in app
backend-1 | await dependant.call(**solved_result.values)
backend-1 | File "/app/routes/generate_code.py", line 349, in stream_code
backend-1 | raise Exception("All generations failed")
backend-1 | Exception: All generations failed
backend-1 | INFO: connection closed
I am using the docker file. Which file do I suppose to modify for the models?
Everything working. now 09/02/2025. the steps is use this script if you are using windows like me
Define the models in an array
$models = @( "claude-3-5-sonnet-20240620", "gpt-4o-2024-05-13", "gpt-4-turbo-2024-04-09", "gpt_4_vision", "claude_3_sonnet" )
Define the source model
$sourceModel = "llama3.2-vision"
foreach ($model in $models) { Write-Output "Copying $sourceModel to $model..." & ollama cp $sourceModel $model }
- please check the name of the models listed and mapped here with ollama is same your app are requesting. i had a error why the app was requesting gpt-4o-2024-11-20 but in my script was using gpt-4o-2024-05-13 , so, keep its in mind and make sure all are right. that's all. and now it will work fine in your PC.
一切正常。现在是 2025 年 9 月 2 日。如果您像我一样使用 Windows,步骤是使用此脚本
在数组中定义模型
$模型=@( “claude-3-5-sonnet-20240620”, “gpt-4o-2024-05-13”, “gpt-4-turbo-2024-04-09”, “gpt_4_vision”, “claude_3_sonnet” )
定义源模型
$sourceModel =“llama3.2-vision”
foreach ($model in $models) { Write-Output “将 $sourceModel 复制到 $model...” & ollama cp $sourceModel $model }
- 请检查此处列出并映射的模型名称与 ollama 是否与您的应用程序请求的相同。我遇到一个错误,为什么应用程序请求 gpt-4o-2024-11-20,但在我的脚本中使用的是 gpt-4o-2024-05-13,因此,请记住这一点并确保一切正确。就这样。现在它可以在您的电脑上正常工作了。
Why do I keep getting an error message:
Received params
Using openAiApiKey from client-side settings dialog
Using openAiBaseURL from client-side settings dialog
Generating html_tailwind code in image mode
Status (variant 0): Generating code...
Status (variant 1): Generating code...
Error generating code. Please contact support.
Traceback (most recent call last):
File "D:\cursor\githubs\screenshot-to-code\backend\llm.py", line 79, in stream_openai_response
stream = await client.chat.completions.create(**params) # type: ignore
我添加到了
OPENAI_LOG=debugcompose.yml 的环境中以查看更多详细信息。我发现openai.NotFoundError: Error code: 404 - {'error': {'message': 'model "gpt-4o-2024-11-20" not found, try pulling it first', 'type': 'api_error', 'param': None, 'code': None}}。我执行了
ollama cp gpt-4o-2024-05-13 gpt-4o-2024-11-20,现在它起作用了。因此以上
gpt-4o-2024-05-13需要更新为gpt-4o-2024-11-20。另请参阅All-Hands-AI/OpenHands#1052。
屏幕截图到代码/后端/路线/generate_code.py
第 270 至 274 行 595d969
elif openai_api_key: 变体模型 = [ 法学硕士。GPT_4O_2024_11_20 , 法学硕士。GPT_4O_2024_11_20 , ] 细节
Why do I keep getting an error message:
Received params
Using openAiApiKey from client-side settings dialog
Using openAiBaseURL from client-side settings dialog
Generating html_tailwind code in image mode
Status (variant 0): Generating code...
Status (variant 1): Generating code...
Error generating code. Please contact support.
Traceback (most recent call last):
File "D:\cursor\githubs\screenshot-to-code\backend\llm.py", line 79, in stream_openai_response
stream = await client.chat.completions.create(**params) # type: ignore