Guest User

smol - forked

a guest
Aug 5th, 2026
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. package main
  2. import ("bufio";
  3. "bytes";
  4. "crypto/rand";
  5. "encoding/json";
  6. "fmt";
  7. "net/http";
  8. "os";
  9. "os/exec")
  10. type M = map[string] any
  11. func main() {
  12. u: = os.Args[1];k: = rand.Text();h: = [] any {};s: = bufio.NewScanner(os.Stdin)
  13. for fmt.Print("> ");s.Scan();fmt.Print("> ") {
  14. if len(bytes.TrimSpace(s.Bytes())) == 0 {
  15. continue
  16. }
  17. h = append(h, M {
  18. "role": "user",
  19. "content": s.Text()
  20. })
  21. for {
  22. b, _: = json.Marshal(M {
  23. "model": "gpt-5.6-sol",
  24. "input": h,
  25. "prompt_cache_key": k,
  26. "tools": [] M {
  27. {
  28. "type": "custom",
  29. "name": "sh"
  30. }
  31. }
  32. })
  33. r, _: = http.Post(u, "application/json", bytes.NewReader(b));
  34. var x M
  35. json.NewDecoder(r.Body).Decode( & x);
  36. r.Body.Close();
  37. o: = x["output"].([] any);
  38. h = append(h, o...);
  39. c: = false
  40. for _, v: = range o {
  41. m: = v.(M);
  42. if m["type"] == "custom_tool_call" {
  43. c = true;
  44. p: = exec.Command("/bin/sh", "-c", m["input"].(string));
  45. q, _: = p.CombinedOutput();
  46. n: = p.ProcessState.ExitCode()
  47. h = append(h, M {
  48. "type": "custom_tool_call_output",
  49. "call_id": m["call_id"],
  50. "output": fmt.Sprintf("exit %d\n%s", n, q)
  51. })
  52. }
  53. }
  54. if !c {
  55. t: = o[len(o) - 1].(M)["content"].([] any)[0].(M)["text"]
  56. z: = x["usage"].(M)["total_tokens"].(float64) * 100 / 1 _050_000;fmt.Printf("%s\n[%06.3f%%]\n", t, z);
  57. break
  58. }
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment