-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpressions.py
More file actions
42 lines (30 loc) · 888 Bytes
/
expressions.py
File metadata and controls
42 lines (30 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# ruff: noqa: T201
import aixen as ai
@ai.fn
def add(a: int, b: int) -> int:
"""
Adds two numbers
"""
return a + b
@ai.chat_fn
def factorial(n: int) -> int:
"""
Calculates the factorial of a number
"""
@ai.chat_fn
def series_formula(seq: list[int]) -> str:
"""
You are given a sequence of integers $x_i$, and you need to find the formula that
generates this sequence.
Provide the result as a LaTeX expression.
ONLY output the LaTeX expression, no text or additional formatting.
<|user|>
{% for x in seq %}{{ x }}, {% endfor %}...
"""
if __name__ == "__main__":
with ai.Context() as context:
print(f"2 + 3 = {add(2, 3)}")
print(f"Factorial of 5 = {factorial(5)}")
seq = [1, 3, 5, 7]
print(f"Series formula: {series_formula(seq)}")
print(f"Cost: ${context.usage_cost_usd}")