support llm gateway callout for script#105
Conversation
| description=( | ||
| "Maximum number of tokens to generate. If None, server default applies." | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Is this a shared interface across Function & Script? If so, are we ok with this option being there for Function, but presumably ignored?
There was a problem hiding this comment.
The customer who's familiar with SFAP public API would expect this param in byoc, right? Currently byoc-proxy does not define this param (proto, but I think it should. Essentially we have three paths that are semi consistent:
- SFAP API: with this PR, both script and function set this new param and it gets sent to SFAP while testing outside
- Script UDF: already defines and honors this param
- grpc to byoc-proxy (used by function): does not define this param.
We have two options:
- Keep this param and have a followup item to support it in grpc, or
- Remove this param from the interface until grpc supports it, meaning the user won't be to use it in UDF either (why? because SFAP route and UDF route use the same interface)
| from datacustomcode.llm_gateway.base import LLMGateway | ||
| from datacustomcode.llm_gateway.default import DefaultLLMGateway | ||
| from datacustomcode.llm_gateway.spark_base import SparkLLMGateway | ||
| from datacustomcode.llm_gateway.spark_default import DefaultSparkLLMGateway |
There was a problem hiding this comment.
Will this pull in pyspark imports into Function runtime?
| from datacustomcode.llm_gateway.spark_base import SparkLLMGateway | ||
|
|
||
| if TYPE_CHECKING: | ||
| from pyspark.sql import Column |
There was a problem hiding this comment.
See note here about whether this will affect Function?
| Returns: | ||
| A Spark ``Column`` that, when evaluated, produces the generated text. | ||
| """ | ||
| gateway = Client()._get_spark_llm_gateway() |
There was a problem hiding this comment.
Why create a new Client() here? Couldn't we use our own?
There was a problem hiding this comment.
Client is a singleton, the same client is reused
Added two methods to allow customers to use their AI models to generate text in Script. In the public sdk, the methods use the public LLM Gateway API (the same used for function), so that the customer can test outside of DC. While running in DC, the methods will be overridden to call the registered spark UDF function.
Sample test and result