Skip to content

Commit b903baf

Browse files
authored
fix(py/samples/xai-hello): get sample to run (#4014)
1 parent e42265e commit b903baf

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

py/noxfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
nox.options.default_venv_backend = 'uv|virtualenv'
2323

2424
PYTHON_VERSIONS = [
25-
#'pypy-3.10', # TODO: Fix build failures.
26-
#'pypy-3.11', # TODO: Fix build failures.
25+
# 'pypy-3.10', # TODO: Fix build failures.
26+
# 'pypy-3.11', # TODO: Fix build failures.
2727
'3.10',
2828
'3.11',
2929
'3.12',
@@ -51,8 +51,8 @@ def tests(session: nox.Session) -> None:
5151
'--isolated',
5252
'pytest',
5353
'-v',
54-
#'-vv',
55-
#'--log-level=DEBUG',
54+
# '-vv',
55+
# '--log-level=DEBUG',
5656
'.',
5757
*session.posargs,
5858
external=True,

py/plugins/xai/pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ classifiers = [
3333
"Topic :: Scientific/Engineering :: Artificial Intelligence",
3434
"Topic :: Software Development :: Libraries",
3535
]
36-
dependencies = [
37-
"genkit",
38-
"xai-sdk>=0.0.1",
39-
]
36+
dependencies = ["genkit", "xai-sdk>=0.0.1"]
4037
description = "Genkit xAI Plugin"
4138
license = { text = "Apache-2.0" }
4239
name = "genkit-plugin-xai"

py/pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ genkit-plugin-google-cloud = { workspace = true }
113113
genkit-plugin-google-genai = { workspace = true }
114114
genkit-plugin-ollama = { workspace = true }
115115
genkit-plugin-vertex-ai = { workspace = true }
116+
genkit-plugin-xai = { workspace = true }
116117
google-genai-hello = { workspace = true }
117118
google-genai-image = { workspace = true }
118119
prompt-demo = { workspace = true }
119-
genkit-plugin-xai = { workspace = true }
120120

121121
[tool.uv.workspace]
122122
members = ["packages/*", "plugins/*", "samples/*"]
@@ -277,8 +277,8 @@ unauthorized_licenses = [
277277
]
278278

279279
[tool.liccheck.authorized_packages]
280-
aiohttp = "3.13.2" # Apache-2.0 AND MIT (transitive dep of xai-sdk)
281-
aiohappyeyeballs = "2.6.1" # Python Software Foundation (transitive dep of xai-sdk)
282-
certifi = "2025.4.26" # TODO: Verify.
283-
dependencies = true
284-
ollama = "0.5.1" # MIT "https://github.com/ollama/ollama-python/blob/main/LICENSE"
280+
aiohappyeyeballs = "2.6.1" # Python Software Foundation (transitive dep of xai-sdk)
281+
aiohttp = "3.13.2" # Apache-2.0 AND MIT (transitive dep of xai-sdk)
282+
certifi = "2025.4.26" # TODO: Verify.
283+
dependencies = true
284+
ollama = "0.5.1" # MIT "https://github.com/ollama/ollama-python/blob/main/LICENSE"

py/samples/xai-hello/src/xai_hello.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,22 @@ async def calculator_flow(expression: str) -> str:
139139
return f'{operation.title()}({a}, {b}) = {result.get("result")}'
140140

141141

142-
if __name__ == '__main__':
143-
import asyncio
142+
async def main():
143+
result = await say_hi('Alice')
144+
logger.info('say_hi', result=result)
145+
146+
result = await say_hi_stream('Bob')
147+
logger.info('say_hi_stream', result=result[:150])
144148

145-
async def main():
146-
result = await say_hi('Alice')
147-
logger.info('say_hi', result=result)
149+
result = await say_hi_with_config('Charlie')
150+
logger.info('say_hi_with_config', result=result)
148151

149-
result = await say_hi_stream('Bob')
150-
logger.info('say_hi_stream', result=result[:150])
152+
result = await weather_flow('New York')
153+
logger.info('weather_flow', result=result)
151154

152-
result = await say_hi_with_config('Charlie')
153-
logger.info('say_hi_with_config', result=result)
155+
result = await calculator_flow('add_5_3')
156+
logger.info('calculator_flow', result=result)
154157

155-
result = await weather_flow('New York')
156-
logger.info('weather_flow', result=result)
157158

158-
result = await calculator_flow('add_5_3')
159-
logger.info('calculator_flow', result=result)
159+
if __name__ == '__main__':
160+
ai.run_main(main())

py/tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ skipsdist = True # We install editable, so don't build sdist.
1010

1111
[testenv]
1212
description = Run tests with pytest
13+
allowlist_externals = uv
1314
deps =
1415
pytest
1516
pytest-cov
1617
pytest-asyncio
1718
pytest-mock
1819
PyYAML
19-
-e .
20+
commands_pre =
21+
uv pip install --python {envpython} -e .
2022
commands =
2123
pytest {posargs}

0 commit comments

Comments
 (0)