Skip to content

Use a cloud based model - #1096

Open
zetter-rpf wants to merge 6 commits into
mainfrom
use-cloud-based-model
Open

zetter-rpf wants to merge 6 commits into
mainfrom
use-cloud-based-model

Conversation

@zetter-rpf

Copy link
Copy Markdown
Contributor

Status

What's changed?

I've adapted what we've already done to use a Cloudflare hosted model instead of a local one

See commits for more

Steps to perform after deploying to production

  • Document how to get access to the gateway from a local machine for testing.
  • Remove the bypass on staging and production by removing BYPASS_FEM_INFERENCE

zetter-rpf and others added 6 commits November 6, 2026 13:56
The responses API is more recent has support for more features such as tool use, however it isn't supported as widely by cloud providers. Specifically, the qwen models we're considering
that is hosted by Cloudflare only supports the chat API.

I think the chat API is sufficient for our use case.

This also makes the mocking easier in the tests with a helper function.

Responses vs chat API: https://developers.openai.com/api/docs/guides/migrate-to-responses

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This qwen model is a suggestion as it's one of the closest to the ones we have previously tested and has a reasonable cost. We will run the evaluator against it to confirm it's suitable.

Note I took out the reasoning config as it changes the structure of the response and causes errors (I'm not sure why). I'll add this back in a future commit
I thought the other method was getting quite complex
When testing we found that reasoning increased cost and time while providing little benefit for the kinds of data we expect. Initially I tried disabling this using the 'reasoning' parameter but this changes the structure of the response. I've not been able to work out why, but assume it is the way this particular model is hosted or configured. Instead I've switched to an alternative way to disable reasoning using the /no_think command.
Having a low temperature makes the models relatively more predictable which is preferred for our needs.

I tested this by asking the model to name an animal.

I still saw variance in responses with a low temperature, but I saw less than with a higher temperature so I assume it's working.
In english, it's common to estimate each token as approximately 4 characters long so should be set to about 1/4 of the max result length. I've added a generous buffer on top of this.
@cla-bot cla-bot Bot added the cla-signed label Nov 6, 2026
@zetter-rpf zetter-rpf changed the title Use cloud based model Use a cloud based model Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Test coverage

94.18% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/42237400454

@macroscopeapp

macroscopeapp Bot commented Nov 6, 2026

Copy link
Copy Markdown

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — This switches friendly-error inference from a local model to Cloudflare, sending learner code and error traces externally when enabled. Before production activation, confirm the provider and gateway’s data-handling, logging and retention controls are appropriate for learner submissions.

Needs human approval because:

  • approvability is in preview mode for this repository, so Macroscope does not approve PRs here

You can add or adjust custom eligibility rules. Learn more.

This branch was successfully deployed

1 active deployment
editor-api-p-use-cloud--ommx4b — d50aaf72 Deployed Nov 6, 2026 by raspberrypiherokubot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants