Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- deepsparse
|
4 |
+
---
|
5 |
+
|
6 |
+
```python
|
7 |
+
from deepsparse import TextGeneration
|
8 |
+
model = TextGeneration(model="hf:mgoin/Nous-Hermes-llama-2-7b-ds")
|
9 |
+
prompt="""### Instruction:
|
10 |
+
Write a Perl script that processes a log file and counts the occurrences of different HTTP status codes. The script should accept the log file path as a command-line argument and print the results to the console in descending order of frequency.
|
11 |
+
|
12 |
+
### Response:
|
13 |
+
"""
|
14 |
+
print(model(prompt, max_new_tokens=500).generations[0].text)
|
15 |
+
```
|
16 |
+
|
17 |
+
Output:
|
18 |
+
```
|
19 |
+
#!/usr/bin/perl
|
20 |
+
|
21 |
+
use strict;
|
22 |
+
use warnings;
|
23 |
+
|
24 |
+
my $log_file = $ARGV[0];
|
25 |
+
|
26 |
+
open(my $fh, '<', $log_file) or die "Could not open file '$log_file' $!";
|
27 |
+
|
28 |
+
my %status_count;
|
29 |
+
|
30 |
+
while (my $line = <$fh>) {
|
31 |
+
chomp $line;
|
32 |
+
|
33 |
+
my @status_codes = split(/\s+/, $line);
|
34 |
+
|
35 |
+
for my $status_code (@status_codes) {
|
36 |
+
$status_count{$status_code}++;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
close($fh);
|
41 |
+
|
42 |
+
foreach my $status_code (sort { $status_count{$b} <=> $status_count{$a} } keys %status_count) {
|
43 |
+
print "$status_code: $status_count{$status_code}\n";
|
44 |
+
}
|
45 |
+
```
|