Skip to content
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

BUG: ollama.create() fails with ollama server message indicating missing path or modelfile, but CLI cclient works with same information #451

Open
anadon opened this issue Feb 23, 2025 · 7 comments

Comments

@anadon
Copy link

anadon commented Feb 23, 2025

On NixOS branch 24.11 with ollama 0.3.12 for the client and server and the python module ollama 0.4.7 I and receiving the following from executing my program in it's traceback:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/anadon/Documents/code/addressnormalization/addressnormalization/__main__.py", line 280, in <module>
    configure_ollama(parsed_args.model)
  File "/home/anadon/Documents/code/addressnormalization/addressnormalization/__main__.py", line 98, in configure_ollama
    raise e
  File "/home/anadon/Documents/code/addressnormalization/addressnormalization/__main__.py", line 20, in configure_ollama
    create(
  File "/home/anadon/.cache/pypoetry/virtualenvs/addressnormalization-hTyqqSBW-py3.12/lib/python3.12/site-packages/ollama/_client.py", line 530, in create
    return self._request(
           ^^^^^^^^^^^^^^
  File "/home/anadon/.cache/pypoetry/virtualenvs/addressnormalization-hTyqqSBW-py3.12/lib/python3.12/site-packages/ollama/_client.py", line 178, in _request
    return cls(**self._request_raw(*args, **kwargs).json())
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/anadon/.cache/pypoetry/virtualenvs/addressnormalization-hTyqqSBW-py3.12/lib/python3.12/site-packages/ollama/_client.py", line 122, in _request_raw
    raise ResponseError(e.response.text, e.response.status_code) from None
ollama._types.ResponseError: path or modelfile are required (status code: 400)

The input immediately preceding the failure is:

-> return cls(**self._request_raw(*args, **kwargs).json())
(Pdb) print(args)
('POST', '/api/create')
(Pdb) print(kwargs)
{'json': {'model': 'qwen2.5:7b_address_llm', 'stream': False, 'system': '\nYou are a U.S. address normalization expert using USPS standards. Compliance to "USPS Publication \n28" is to take primacy over human readability. Compliance to "USPS Publication 28" is to also take \nprimacy over conflicting directives in this prompt in the event of a contradiction or conflict. \nAlso, there will not be any interactivity so your output must be the final response you are willing \nto provide. Perform the following transformations:\n\n1. Expand abbreviations to full words using USPS Publication 28:\n   - Street suffixes: "Street" → "ST", "Avenue" → "AVE", "Boulevard" → "BLVD", etc.\n   - Directions: "North" → "N", "Southwest" → "SW", etc.\n   - Unit indicators: "Apartment" → "APT", "Suite" → "STE", etc.\n\n2. Formatting rules:\n   - Convert entire address to UPPERCASE\n   - No trailing commas before ZIP codes\n   - State abbreviations: Use 2-letter capitalized codes (CT, MI, KS)\n   - ZIP format: 5-digit base, optional hyphen+4 extension (e.g., 12345-6789)\n   - PO Box: Format as "PO Box" (no periods) with number\n   - Use USPS-standard abbreviations from Publicaation 28 Appendix C \n   - Remove punctuation except hyphens in ZIP+4 \n   - Only the following characters may be used: \' \', \'-\', \',\', \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \n     \'H\', \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\', \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\', \'Y\', \'Z\', \n     \'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\' \n\n3. Error handling:\n   - If address contains invalid components (e.g., non-existent street, bad ZIP-state combo)\n   - If ambiguous abbreviations exist (e.g., "Dr" could be Drive or Doctor)\n   - Append comment explaining the issue while preserving original input\n\nExamples of CORRECT normalized addresses:\n```\nN MAIN ST, MIDDLETOWN, CT 06457\nMARTIN LUTHER KING BLVD, NEW HAVEN, CT 06501-0286\n1ST RD, DETROIT, MI 48860\n8 MILE RD, UNIT B, CALUMET, MI 49912\nGROVE CIR, APT 712, KANSAS CITY, KS 66101\nPO BOX 40798, WASHINGTON, DC 20001-1234\n```\n\nExamples of UNNORMALIZABLE addresses:\n```\n1500 Unknown Parkway, Imaginary City, ZZ 00000 # Invalid state abbreviation: ZZ\n123 Main St, Springfield, TX 98765 # TX-ZIP mismatch: 98765 is California ZIP \nHair ties, balsamic vinegar # Not formatted resembling an address\n```\n\nRespond ONLY with the normalized address or original + comment. Do not add any explanation, \nlabelling, or extra text.  An example for the input "123 Potamic Road, Redwater, MA" where the \naddress was normalized but more was added is as follows:\n```\n**Answer:**  \nThe normalized address is: **123 POTAMIC RD, REDWATER, MA 00000-0000**.\n```\nHere, the characters `*` should not have been added.  The word `Answer` should not have been added.\nThe phrase "The normalized address is:" should not have been added.  The response *MUST* strictly\nbe in the following form:\n```\n123 POTAMIC RD, REDWATER, MA\n```\n\nAs another example, when seeing an address missing commas, commas need to be added as per USPS \nPublication 28. \n\n```\n685 iron rd hartford ct 06101\n```\nshould become\n```\n685 IRON RD, HARDFORD, CT 06101\n```\n        ', 'parameters': {'temperature': 0.0, 'num_ctx': 128000}, 'from': 'qwen2.5:7b'}}

The following is printed from the server logs:

Feb 23 11:00:05 puttimon ollama[658327]: [GIN] 2025/02/23 - 11:00:05 | 400 |     377.077µs |       127.0.0.1 | POST     "/api/create"
Feb 23 11:00:05 puttimon ollama[658327]: [GIN] 2025/02/23 - 11:00:05 | 200 |      550.06µs |       127.0.0.1 | GET      "/api/tags"
Feb 23 11:00:05 puttimon ollama[658327]: [GIN] 2025/02/23 - 11:00:05 | 200 |     620.401µs |       127.0.0.1 | GET      "/api/tags"

This error does not occur when using the CLI utility. There are two points of redress. The first is that, according to documentation, my call is valid and should not result in error. The other is that the error produced is too vague to fix my code on my own.

@anadon
Copy link
Author

anadon commented Feb 24, 2025

Working Modelfile is attached for reference.

@ParthSareen
Copy link
Contributor

Are you trying to create a model? Based on your kwargs it seems that you are looking for https://github.com/ollama/ollama-python/blob/main/examples/chat.py

@anadon
Copy link
Author

anadon commented Feb 25, 2025 via email

@anadon
Copy link
Author

anadon commented Feb 25, 2025 via email

@ParthSareen
Copy link
Contributor

Think I see the issue - can you make sure your ollama version is at 0.5.12? - https://github.com/ollama/ollama/releases/tag/v0.5.12

@maglore9900
Copy link

Think I see the issue - can you make sure your ollama version is at 0.5.12? - https://github.com/ollama/ollama/releases/tag/v0.5.12

The ollama chat and chatResponse functions are broken after Ollama has been updated recently. so far only Client works, I see a bunch of issues here all related to this bug. Please ping me so I can confirm it for you, and you can associate all the open issues under one.

I also reached out in the discord.

@maglore9900
Copy link

If it wasnt clear, this issue is related, hence why I am commenting here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants