Skip to content

Commit 8b47c4a

Browse files
authored
Merge pull request #20 from aboutcode-org/tutorial
Add tutorial for end to end Gen AI code search
2 parents f91dec3 + 00a8e07 commit 8b47c4a

21 files changed

+161
-0
lines changed

CHANGELOG.rst

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
============
44

55

6+
7+
v1.0.0
8+
------
9+
10+
- Add tutorial
11+
12+
613
v0.5.1
714
------
815

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
Step-by-step: Find AI-generated code with AboutCode
2+
========================================================
3+
4+
5+
In this tutorial, we first generate code using ChatGPT, then scan the generated code in ScanCode
6+
using the MatchCode pipeline.
7+
8+
9+
- Visit https://chatgpt.com/.
10+
11+
- Enter this prompt to generate code:
12+
13+
``Write JS code that is similar to https://github.com/isaacs/inherits/``
14+
15+
+-----------------------------------------------------------+
16+
| .. image:: images/image_2.jpg |
17+
| :width: 600 |
18+
+-----------------------------------------------------------+
19+
20+
- The results will look something like this:
21+
22+
23+
+-----------------------------------------------------------+
24+
| .. image:: images/chatgpt_1.png |
25+
| :width: 600 |
26+
+-----------------------------------------------------------+
27+
28+
- Click "Copy" button to copy the generated code then paste this in a text editor to save the
29+
generated code to a file named "foo.js":
30+
31+
+-----------------------------------------------------------+
32+
| .. image:: images/image_4.jpg |
33+
| :width: 600 |
34+
+-----------------------------------------------------------+
35+
36+
37+
- Next, open your ScanCode.io URL and click on the "New Project" button.
38+
39+
+-----------------------------------------------------------+
40+
| .. image:: images/image_3.jpg |
41+
| :width: 600 |
42+
+-----------------------------------------------------------+
43+
44+
45+
- Click "Drop files over here (or click)" and upload the saved "foo.js" file.
46+
47+
+-----------------------------------------------------------+
48+
| .. image:: images/image_5.jpg |
49+
| :width: 600 |
50+
+-----------------------------------------------------------+
51+
52+
53+
- Then select the initial "scan_codebase" pipeline and click the "Create" button:
54+
55+
+-----------------------------------------------------------+
56+
| .. image:: images/image_7.jpg |
57+
| :width: 600 |
58+
+-----------------------------------------------------------+
59+
60+
- Click "Add pipeline" button.
61+
62+
+-----------------------------------------------------------+
63+
| .. image:: images/image_8.jpg |
64+
| :width: 600 |
65+
+-----------------------------------------------------------+
66+
67+
- Then select the "fingerprint_codebase" and cliem the "Add pipeline" button.
68+
69+
+-----------------------------------------------------------+
70+
| .. image:: images/image_9.jpg |
71+
| :width: 600 |
72+
+-----------------------------------------------------------+
73+
74+
- Repeat with the "match_to_matchcode" pipeline:
75+
76+
+-----------------------------------------------------------+
77+
| .. image:: images/image_12.jpg |
78+
| :width: 600 |
79+
+-----------------------------------------------------------+
80+
81+
- When the scan is done, click the "Resources" link to see the match results
82+
83+
+-----------------------------------------------------------+
84+
| .. image:: images/image_14.jpg |
85+
| :width: 600 |
86+
+-----------------------------------------------------------+
87+
88+
- You can see the file was matched to the "pkg:github/isaacs/inherits@v2.0.3" PURL. This is for
89+
this package: https://github.com/isaacs/inherits/
90+
91+
+-----------------------------------------------------------+
92+
| .. image:: images/image_15.jpg |
93+
| :width: 600 |
94+
+-----------------------------------------------------------+
95+
96+
97+
- Click on "pkg:github/isaacs/inherits@v2.0.3" package link.
98+
99+
+-----------------------------------------------------------+
100+
| .. image:: images/image_16.jpg |
101+
| :width: 600 |
102+
+-----------------------------------------------------------+
103+
104+
- From there click on the "Resources" tab:
105+
106+
+-----------------------------------------------------------+
107+
| .. image:: images/image_17.jpg |
108+
| :width: 600 |
109+
+-----------------------------------------------------------+
110+
111+
- Click the "foo.js" link to see the file details.
112+
113+
+-----------------------------------------------------------+
114+
| .. image:: images/image_18.jpg |
115+
| :width: 600 |
116+
+-----------------------------------------------------------+
117+
118+
- Click on the "Viewer" tab to see the file content.
119+
120+
+-----------------------------------------------------------+
121+
| .. image:: images/image_19.jpg |
122+
| :width: 600 |
123+
+-----------------------------------------------------------+
124+
125+
- Click "Matched Snippets" sub-tab of the viewer to see the highlighted matched code:
126+
127+
+-----------------------------------------------------------+
128+
| .. image:: images/image_20.jpg |
129+
| :width: 600 |
130+
+-----------------------------------------------------------+
131+
132+
133+
- The AI-generated code is highlighted as matched code below:
134+
135+
+-----------------------------------------------------------+
136+
| .. image:: images/image_21.png |
137+
| :width: 600 |
138+
+-----------------------------------------------------------+
139+
140+
141+
- The matched original code is also highlighted for reference:
142+
https://github.com/isaacs/inherits/blob/v2.0.3/inherits_browser.js
143+
144+
+-----------------------------------------------------------+
145+
| .. image:: images/image_22.png |
146+
| :width: 600 |
147+
+-----------------------------------------------------------+
148+

docs/source/e2e/images/chatgpt_1.png

103 KB
Loading

docs/source/e2e/images/image_12.jpg

61.7 KB
Loading

docs/source/e2e/images/image_14.jpg

44.7 KB
Loading

docs/source/e2e/images/image_15.jpg

32.4 KB
Loading

docs/source/e2e/images/image_16.jpg

30.2 KB
Loading

docs/source/e2e/images/image_17.jpg

36.6 KB
Loading

docs/source/e2e/images/image_18.jpg

25.1 KB
Loading

docs/source/e2e/images/image_19.jpg

26.7 KB
Loading

docs/source/e2e/images/image_2.jpg

22.6 KB
Loading

docs/source/e2e/images/image_20.jpg

53.6 KB
Loading

docs/source/e2e/images/image_21.png

172 KB
Loading

docs/source/e2e/images/image_22.png

138 KB
Loading

docs/source/e2e/images/image_3.jpg

95.8 KB
Loading

docs/source/e2e/images/image_4.jpg

57.8 KB
Loading

docs/source/e2e/images/image_5.jpg

84.4 KB
Loading

docs/source/e2e/images/image_7.jpg

84.3 KB
Loading

docs/source/e2e/images/image_8.jpg

41.5 KB
Loading

docs/source/e2e/images/image_9.jpg

60.8 KB
Loading

docs/source/index.rst

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ using AI code genertion.
1717
contributing
1818
code-of-conduct
1919

20+
.. toctree::
21+
:maxdepth: 2
22+
:caption: Tutorials
23+
24+
e2e/detect-ai-gen-code.rst
25+
2026
.. toctree::
2127
:maxdepth: 2
2228
:caption: SameCode library

0 commit comments

Comments
 (0)