rubber-ducky 1.1.3__py3-none-any.whl → 1.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ducky/ducky.py CHANGED
@@ -1,29 +1,29 @@
1
1
  import argparse
2
2
  import asyncio
3
- from typing import Optional
4
3
  from ollama import AsyncClient
5
4
 
6
5
 
7
6
  class RubberDuck:
8
- def __init__(self, model: str = "codellama") -> None:
9
- self.system_prompt = """You are a pair progamming tool to help developers debug, think through design, and write code.
10
- Help the user think through their approach and provide feedback on the code. Think step by step and ask clarifying questions if needed."""
7
+ def __init__(self, model: str, quick: bool = False) -> None:
8
+ self.system_prompt = """You are a pair progamming tool called Ducky or RubberDucky to help developers debug, think through design, and write code.
9
+ Help the user think through their approach and provide feedback on the code. Think step by step and ask clarifying questions if needed.
10
+ If asked """
11
11
  self.client = AsyncClient()
12
12
  self.model = model
13
+ self.quick = quick
14
+
15
+ async def call_llm(self, prompt: str | None = None) -> None:
16
+ chain = False if prompt else True
13
17
 
14
- async def call_llama(self, code: str = "", prompt: Optional[str] = None, chain: bool = False) -> None:
15
18
  if prompt is None:
16
- user_prompt = input("\nEnter your prompt (or press Enter for default review): ")
17
- if not user_prompt:
18
- prompt = "review the code, find any issues if any, suggest cleanups if any:" + code
19
- else:
20
- prompt = user_prompt + code
21
- else:
22
- prompt = prompt + code
23
-
24
- responses = []
19
+ prompt = input("\nEnter your prompt (or press Enter for default review): ")
20
+
21
+ if self.quick:
22
+ prompt += ". Return a command and be extremely concise"
23
+
24
+ print(prompt)
25
+ responses = [self.system_prompt]
25
26
  while True:
26
- # Include previous responses in the prompt for context
27
27
  context_prompt = "\n".join(responses) + "\n" + prompt
28
28
  stream = await self.client.generate(model=self.model, prompt=context_prompt, stream=True)
29
29
  response_text = ""
@@ -31,11 +31,11 @@ class RubberDuck:
31
31
  if 'response' in chunk:
32
32
  print(chunk['response'], end='', flush=True)
33
33
  response_text += chunk['response']
34
- print() # New line after response completes
34
+ print()
35
35
  responses.append(response_text)
36
36
  if not chain:
37
37
  break
38
- prompt = input("\nAny questions? \n")
38
+ prompt = input("\n>> ")
39
39
 
40
40
 
41
41
  def read_files_from_dir(directory: str) -> str:
@@ -54,6 +54,7 @@ async def ducky() -> None:
54
54
  parser.add_argument("--prompt", "-p", help="Custom prompt to be used", default=None)
55
55
  parser.add_argument("--file", "-f", help="The file to be processed", default=None)
56
56
  parser.add_argument("--directory", "-d", help="The directory to be processed", default=None)
57
+ parser.add_argument("--quick", "-q", help="Quick mode", default=False)
57
58
  parser.add_argument(
58
59
  "--chain",
59
60
  "-c",
@@ -62,36 +63,29 @@ async def ducky() -> None:
62
63
  default=False,
63
64
  )
64
65
  parser.add_argument(
65
- "--model", "-m", help="The model to be used", default="codellama"
66
+ "--model", "-m", help="The model to be used", default="qwen2.5-coder"
66
67
  )
67
68
  args, _ = parser.parse_known_args()
68
69
 
69
- # My testing has shown that the codellama:7b-python is good for returning python code from the program.
70
- # My intention with this tool was to give more general feedback and have back a back and forth with the user.
71
- rubber_ducky = RubberDuck(model=args.model)
70
+ rubber_ducky = RubberDuck(model=args.model, quick=args.quick)
72
71
 
73
72
  # Handle direct question from CLI
74
- if args.question is not None:
75
- question = " ".join(args.question) + " be as concise as possible"
76
- await rubber_ducky.call_llama(prompt=question, chain=args.chain)
73
+ print(args.question)
74
+ if args.question:
75
+ question = " ".join(args.question)
76
+ await rubber_ducky.call_llm(prompt=question)
77
77
  return
78
78
 
79
+ # Handle interactive mode (no file/directory specified)
79
80
  if args.file is None and args.directory is None:
80
- # Handle interactive mode (no file/directory specified)
81
- await rubber_ducky.call_llama(prompt=args.prompt, chain=args.chain)
82
- if args.chain:
83
- while True:
84
- await rubber_ducky.call_llama(prompt=args.prompt, chain=args.chain)
81
+ await rubber_ducky.call_llm(prompt=args.prompt)
85
82
  return
86
83
 
87
- # Handle file input
88
- if args.file is not None:
89
- code = open(args.file).read()
90
- # Handle directory input
91
- else:
92
- code = read_files_from_dir(args.directory)
93
-
94
- await rubber_ducky.call_llama(code=code, prompt=args.prompt, chain=args.chain)
84
+ # Get code from file or directory
85
+ code = (open(args.file).read() if args.file
86
+ else read_files_from_dir(args.directory))
87
+
88
+ await rubber_ducky.call_llm(code=code, prompt=args.prompt)
95
89
 
96
90
 
97
91
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rubber-ducky
3
- Version: 1.1.3
3
+ Version: 1.1.4
4
4
  Summary: AI Companion for Pair Programming
5
5
  Home-page: https://github.com/ParthSareen/ducky
6
6
  Author: Parth Sareen
@@ -0,0 +1,8 @@
1
+ ducky/__init__.py,sha256=_7imP8Jc2SIapn4fzGkspmKvqxPTFDcDJWHZ_o_MnlE,24
2
+ ducky/ducky.py,sha256=wJZMwjyw3JQnNcKwOdhO05l86OUfL1iEVnkBkvYGPss,3292
3
+ rubber_ducky-1.1.4.dist-info/LICENSE,sha256=gQ1rCmw18NqTk5GxG96F6vgyN70e1c4kcKUtWDwdNaE,1069
4
+ rubber_ducky-1.1.4.dist-info/METADATA,sha256=CCn5Tdj5miUeDSELtNVe8y85btA0XbZkcey-gs6Orpk,1736
5
+ rubber_ducky-1.1.4.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
6
+ rubber_ducky-1.1.4.dist-info/entry_points.txt,sha256=LPndtj8UqEWtwYApv5LJJniH4FUrsriOqV2LA1X_UPQ,43
7
+ rubber_ducky-1.1.4.dist-info/top_level.txt,sha256=4Q75MONDNPpQ3o17bTu7RFuKwFhTIRzlXP3_LDWQQ30,6
8
+ rubber_ducky-1.1.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: setuptools (75.7.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- ducky/__init__.py,sha256=_7imP8Jc2SIapn4fzGkspmKvqxPTFDcDJWHZ_o_MnlE,24
2
- ducky/ducky.py,sha256=OV66MC2-tfimWo5nEBemdKrznFuzp3dOOoJq_P2f2Dk,3859
3
- rubber_ducky-1.1.3.dist-info/LICENSE,sha256=gQ1rCmw18NqTk5GxG96F6vgyN70e1c4kcKUtWDwdNaE,1069
4
- rubber_ducky-1.1.3.dist-info/METADATA,sha256=0MKpJ0cTvHulAjWBiwwesXv3Zlvy5p9764Xi2GI-Oq8,1736
5
- rubber_ducky-1.1.3.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
6
- rubber_ducky-1.1.3.dist-info/entry_points.txt,sha256=LPndtj8UqEWtwYApv5LJJniH4FUrsriOqV2LA1X_UPQ,43
7
- rubber_ducky-1.1.3.dist-info/top_level.txt,sha256=4Q75MONDNPpQ3o17bTu7RFuKwFhTIRzlXP3_LDWQQ30,6
8
- rubber_ducky-1.1.3.dist-info/RECORD,,